From: D-Man <ds...@ri...> - 2001-07-19 15:58:54
|
On Thu, Jul 19, 2001 at 03:57:38PM +0200, Kevin McNamee wrote: | | I am trying to use threads so that I can revalidate some panes while | performing a series of long tasks, i.e. | | long task | update & revalidate pane | long task | update & revalidate pane | etc. Ok. You have this loop in a thread (some subclass of java.lang.Thread). When you want to update the GUI you update it via the SwingUtilities class. Ex : class MyThread( java.lang.Thread ) : def run( self ) : for ... : ... # now update the GUI, create an java.lang.Runnable that # does the work class updater( java.lang.Runnable ) : def run( self ) : <update the gui here> if javax.swing.SwingUtilities.isEventDispatchThread() : # we are already in the AWT_EventQueue thread, it is # safe to touch the GUI updater().run() else : # request that the updater be run in the # AWT_EventQueue thread javax.swing.SwingUtilities.invokeLater( updater() ) HTH, -D |