GUI update and threads
From: Karsten Wutzke (kwutzke-blahblah_at_emporis.com)
Date: 03/31/04
- Previous message: Will Friedman: "Multiple actions for a single key press"
- Next in thread: A. Bolmarcich: "Re: GUI update and threads"
- Reply: A. Bolmarcich: "Re: GUI update and threads"
- Reply: Olivier Chafik: "Re: GUI update and threads"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 31 Mar 2004 00:03:34 +0200
Hello all!
I use Observer-Observable to update my GUI when desired (setChanged,
notifyObservers). However, I sometimes get an exception irregularly:
java.lang.ArrayIndexOutOfBoundsException: No such child: 4
at java.awt.Container.getComponent(Container.java:237)
at javax.swing.JComponent.rectangleIsObscured(JComponent.java:3705)
at javax.swing.JComponent.paint(JComponent.java:806)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4795)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4748)
at javax.swing.JComponent._paintImmediately(JComponent.java:4692)
at javax.swing.JComponent.paintImmediately(JComponent.java:4495)
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.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
I have three threads running which call methods on objects that lead to
an update of the GUI, so I assume it's a threading problem (due to the
irregularities).
I remember from some time ago, that there was a way to have the AWT
thread handle the repaint (or was it the event dispatcher? or are they
the same?).
Does anyone know how I can post the GUI updates to the "Java GUI repaint
thread"? I can't remember how it was done, I think it was a simple
static method call on some class, but which one?
Can anyone make some other suggestions as to what I could try?
Thanks very much!
Karsten
- Previous message: Will Friedman: "Multiple actions for a single key press"
- Next in thread: A. Bolmarcich: "Re: GUI update and threads"
- Reply: A. Bolmarcich: "Re: GUI update and threads"
- Reply: Olivier Chafik: "Re: GUI update and threads"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|