JDK-6342641 : ArrayIndexOutOfBoundException when moving Swing app into secondary monitor
  • Type: Bug
  • Component: client-libs
  • Sub-Component: 2d
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2005-10-27
  • Updated: 2010-04-02
  • Resolved: 2007-02-15
Related Reports
Duplicate :  
Relates :  
Description
Steps to reproduce:
1) Configure your Win XP so that it's using just one primary monitor, have secondary monitor available but disabled.
2) Run SwingSet2 demo application
3) Enable secondary display in OS settings, wait for display to enlightent itself :-)
4) Drag SwingSet2 window to secondary monitor area

Result: AIOOBE thrown:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException:
 1
        at sun.awt.windows.WWindowPeer.updateGC(WWindowPeer.java:264)
        at sun.awt.windows.WWindowPeer.displayChanged(WWindowPeer.java:291)
        at sun.awt.windows.WWindowPeer$1.run(WWindowPeer.java:235)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThre
ad.java:273)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.
java:183)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThre
ad.java:173)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

Comments
EVALUATION This bug is covered by the fix for 4417798: Need to track add/remove of monitors on display changes so I'm closing it as a duplicate.
15-02-2007

EVALUATION This is a known issue - see 4417795. The problem here is that we need not to simply update the number of monitors present in the system each time we access them, but to create a new drawing surface for them, init DirectX and many other things.
28-10-2005

SUGGESTED FIX *** /tmp/geta19825 28 15:05:13 2005 --- awt_Win32GraphicsEnv.cpp 28 15:05:07 2005 *************** *** 92,97 **** --- 92,98 ---- int getScreenFromMHND(MHND mon) { DASSERT(mon != NULL); + awt_numScreens = ::CountMonitors(); for (int i = 0; i < awt_numScreens; i++) { if (areSameMonitors(mon, getMHNDFromScreen(i))) {
28-10-2005

EVALUATION I'm unable to reproduce the whole scenario but looking on the sources may predict the wrong place. WWindowPeer accessing an array of Screens: Win32GraphicsDevice newDev = (Win32GraphicsDevice)GraphicsEnvironment .getLocalGraphicsEnvironment().getScreenDevices()[scrn]; scrn is actually == awt_Window:GetScreenImOn() and in turn scrn == getScreenFromMHND(hmon); We use awt_numScreens variable in getScreenFromMHND(hmon) to through all monitors but seems that variable is only initializes here: void initScreens(JNIEnv *env) { awt_numScreens = ::CountMonitors(); .... Not sure if calling that method before counting again will solve the problem - should run application to verify.
28-10-2005