Exception occurred during event dispatching

J

jobs239

I sometimes get the following exception when I bring up my GUI. Line
723 of the code where it originates has the following code.

JOptionPane.showMessageDialog(comp, msg, title, err_type);

I tried putting a try catch statement around this to catch the
arrayoutofbounds exception but it doesn't seem to work. Please help me
debug this problem?


Exception occurred during event dispatching:
java.lang.ArrayIndexOutOfBoundsException: 1
at
javax.swing.plaf.basic.BasicTabbedPaneUI.paintTabArea(BasicTabbedPaneUI.java:535)
at
javax.swing.plaf.basic.BasicTabbedPaneUI$ScrollableTabPanel.paintComponent(BasicTabbedPaneUI.java:2960)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JViewport.paint(JViewport.java:722)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JSplitPane.paintChildren(JSplitPane.java:1021)
at javax.swing.JComponent.paint(JComponent.java:817)
at
javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4787)
at
javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
at
javax.swing.JComponent._paintImmediately(JComponent.java:4685)
at
javax.swing.JComponent.paintImmediately(JComponent.java:4488)
at
javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at
javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
at
java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:141)
at java.awt.Dialog$1.run(Dialog.java:540)
at java.awt.Dialog.show(Dialog.java:561)
at
javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:840)
at
javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:642)
at
javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:613)
at myprog.ide.AnUtility$3.run(AnUtility.java:723)
at
java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at
java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
 
T

Thomas Hawtin

I sometimes get the following exception when I bring up my GUI. Line
723 of the code where it originates has the following code.

JOptionPane.showMessageDialog(comp, msg, title, err_type);

I tried putting a try catch statement around this to catch the
arrayoutofbounds exception but it doesn't seem to work. Please help me
debug this problem?


Exception occurred during event dispatching:
java.lang.ArrayIndexOutOfBoundsException: 1
at
javax.swing.plaf.basic.BasicTabbedPaneUI.paintTabArea(BasicTabbedPaneUI.java:535)
[...]

I suggest you look at the source for
javax.swing.plaf.basic.BasicTabbedPaneUI.paintTabArea and search
bugs.sun.com.

If you still can't figure it out. Try a debugger. Write the smallest
possible example that doesn't work. If it's still unclear post back
here, with complete short example of version number.

FWIW, if it's that simple, I'd guess it's to do with working with Swing
outside of the Event Dispatch Thread (EDT).

Tom Hawtin
 
R

Roedy Green

I tried putting a try catch statement around this to catch the
arrayoutofbounds exception but it doesn't seem to work. Please help me
debug this problem?

Your catch will have to be in the event handler, not the code that
set up the event handler.

Normally you don't catch ArrayBoundsExceptions. You fix the bug
causing them. Catching them just sweeps the dirt under the rug.



--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
R

Roedy Green

I suggest you look at the source for
javax.swing.plaf.basic.BasicTabbedPaneUI.paintTabArea and search
bugs.sun.com.

keep in mind the big restriction that Swing is single thread. You
can't call Swing methods directly from other that the Swing thread.

All guarantees are off what will happen if you violate that rule.

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
N

Nigel Wade

I sometimes get the following exception when I bring up my GUI. Line
723 of the code where it originates has the following code.

JOptionPane.showMessageDialog(comp, msg, title, err_type);

I tried putting a try catch statement around this to catch the
arrayoutofbounds exception but it doesn't seem to work. Please help me
debug this problem?


Exception occurred during event dispatching:
java.lang.ArrayIndexOutOfBoundsException: 1
at
javax.swing.plaf.basic.BasicTabbedPaneUI.paintTabArea(BasicTabbedPaneUI.java:535)
javax.swing.plaf.basic.BasicTabbedPaneUI$ScrollableTabPanel.paintComponent(BasicTabbedPaneUI.java:2960)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JViewport.paint(JViewport.java:722)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JComponent.paint(JComponent.java:817)
at javax.swing.JComponent.paintChildren(JComponent.java:647)
at javax.swing.JSplitPane.paintChildren(JSplitPane.java:1021)
at javax.swing.JComponent.paint(JComponent.java:817)
at
javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4787)
at
javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4740)
at
javax.swing.JComponent._paintImmediately(JComponent.java:4685)
at
javax.swing.JComponent.paintImmediately(JComponent.java:4488)
at
javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at
javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
at
java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:141)
at java.awt.Dialog$1.run(Dialog.java:540)
at java.awt.Dialog.show(Dialog.java:561)
at
javax.swing.JOptionPane.showOptionDialog(JOptionPane.java:840)
at
javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:642)
at
javax.swing.JOptionPane.showMessageDialog(JOptionPane.java:613)
at myprog.ide.AnUtility$3.run(AnUtility.java:723)
at
java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at
java.awt.EventDispatchThread.run(EventDispatchThread.java:100)


Intermittent Exceptions during GUI initialization can be an indication of
the fact that the GUI is being initialized in the main thread after the EDT
has started realizing it. The Exception is raised because the EDT is
attempting to display a component which is in the process of being modified
by the main thread, or has not been properly initialized yet. The reason
it's intermittent is because it's a race condition.

If this is the case you either need to re-organize the GUI creation so that
nothing is realized until the main thread has completed all its
inialization (and so the EDT is not started), or put the entire
initialization in a separate method and pass off that method to
SwingUtilities.invokeLater() and let the EDT do all the initializtion.

The latter is the preferred method.

See:
http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html#EDT
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top