Meaningless Drivel is fun!*
The moose likes Threads and Synchronization and the fly likes updating GUI from another thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "updating GUI from another thread" Watch "updating GUI from another thread" New topic

updating GUI from another thread

Mikko Kohtamäki
Ranch Hand

Joined: Dec 13, 2008
Posts: 112
I have one Thread that is working as a queue for another two thread which process the data. I may call them as DataLoader and DataProcessors.

DataLoader fires events how the progress is going on, or if processing is finished, cancelled, paused, etc. Say I want to disable some buttons when event is fired.

First I fired events using invokeLater() from DataLoader, I noticed that nothing happens. After this event fired (I had disable button code in JButton action for testing) I pressed the button, disablation works on second pressing time wtf... Please explain me why?

I have got it working by calling invokeLater() in GUI code (Listener) and run the buttons disablation code inside it.
Mikko Kohtamäki
Ranch Hand

Joined: Dec 13, 2008
Posts: 112
Well this was not a thread issue (Swing issue), I posted too early. Sorry...

Issue solved, OptionPaneUI uninstalls and installs components after almost every property change. In where I wanted disable buttons.
I agree. Here's the link:
subject: updating GUI from another thread
Similar Threads
AWT/Swing Event Threads vs SWT - Rob?
NX: concerning the event-dispatching thread
invokeLater - what's the skinny?
B&S: Multi threading, Swing, SwingWorker