jdk/src/windows/classes/sun/awt/Win32GraphicsEnvironment.java
Print this page
@@ -91,11 +91,16 @@
protected native int getNumScreens();
protected native int getDefaultScreen();
public GraphicsDevice getDefaultScreenDevice() {
- return getScreenDevices()[getDefaultScreen()];
+ GraphicsDevice[] screens = getScreenDevices();
+ if (screens.length == 0) {
+ return null;
+ }
+ 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