Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating JFrame from another JFrame

Status
Not open for further replies.

BillyKrow

Programmer
Aug 27, 2001
67
0
0
US
I have a simple task. I want to hide/show and update text in a JFrame asynchronously from another JFrame. It seems the code in the parent frame must complete before the other frame will update.

I've tried threads and the SwingUtilities.invokeLater method but I can't get it to work then again, I don't really know what I'm doing. There's a got to be a simple example of doing this but I've yet to find anything that works.
 
Could you ellaborate "asynchronously"?

If you mean "in paralel" you'd need another thread, but remember that UI updates are held in the Swing thread, so there will be an execution order.

Maybe it's worth having a look at the invokeAndWait method.

Cheers,
Dian
 
Asycrhonously meaning I'm running a process that is taking time and while it's running I want a simple JFrame status "processing..." type pop up. The problem is I can get the popup to come up, but the text won't appear until processing is done. I can get it to work if I thread the the main process but this causes other problems. Really I need to thread status window itself. I've tried the invokeAndWait method but then you don't even see the popup JFrame until the main process is done.
 
Actually, I have a correction to above. When I use the invokeAndWait method I get an error "Cannot call invokeAndWait from the event dispatcher thread
 
That won't work either. Main problem was all processing is being fired from a keyboard listener. Solution was to add another keyboard listner class that's only responsibility is to update the status message. Since this is it's only job, it finishes quickly and can update the status while the other listener is doing all the work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top