--- old/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java 2013-09-23 21:56:08.391769700 +0400 +++ new/jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java 2013-09-23 21:56:07.920742700 +0400 @@ -25,6 +25,7 @@ package sun.awt; +import java.awt.AWTError; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; @@ -93,7 +94,9 @@ protected native int getDefaultScreen(); public GraphicsDevice getDefaultScreenDevice() { - return getScreenDevices()[getDefaultScreen()]; + GraphicsDevice[] screens = getScreenDevices(); + int index = getDefaultScreen(); + return screens[0 < index && index < screens.length ? index : 0]; } /** @@ -127,6 +130,9 @@ public void displayChanged() { // getNumScreens() will return the correct current number of screens GraphicsDevice newDevices[] = new GraphicsDevice[getNumScreens()]; + if (newDevices.length == 0) { + throw new AWTError("no screen devices"); + } GraphicsDevice oldScreens[] = screens; // go through the list of current devices and determine if they // could be reused, or will have to be replaced