jdk/src/solaris/classes/sun/awt/X11GraphicsEnvironment.java

Print this page

        

@@ -198,11 +198,13 @@
     protected native int getDefaultScreenNum();
     /**
      * Returns the default screen graphics device.
      */
     public GraphicsDevice getDefaultScreenDevice() {
-        return getScreenDevices()[getDefaultScreenNum()];
+        GraphicsDevice[] screens = getScreenDevices();
+        int index = getDefaultScreenNum();
+        return screens[0 < index && index < screens.length ? index : 0];
     }
 
     public boolean isDisplayLocal() {
         if (isDisplayLocal == null) {
             SunToolkit.awtLock();