jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java

Print this page

        

*** 23,32 **** --- 23,33 ---- * questions. */ package sun.awt; + import java.awt.AWTError; import java.awt.GraphicsConfiguration; import java.awt.GraphicsDevice; import java.awt.GraphicsEnvironment; import java.awt.Toolkit; import java.awt.peer.ComponentPeer;
*** 91,101 **** protected native int getNumScreens(); protected native int getDefaultScreen(); public GraphicsDevice getDefaultScreenDevice() { ! return getScreenDevices()[getDefaultScreen()]; } /** * Returns the number of pixels per logical inch along the screen width. * In a system with multiple display monitors, this value is the same for --- 92,104 ---- protected native int getNumScreens(); protected native int getDefaultScreen(); public GraphicsDevice getDefaultScreenDevice() { ! GraphicsDevice[] screens = getScreenDevices(); ! int index = getDefaultScreen(); ! return screens[0 < index && index < screens.length ? index : 0]; } /** * Returns the number of pixels per logical inch along the screen width. * In a system with multiple display monitors, this value is the same for
*** 125,134 **** --- 128,140 ---- */ @Override 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 if (oldScreens != null) { for (int i = 0; i < oldScreens.length; i++) {