*
The moose likes Swing / AWT / SWT and the fly likes refreshing the jframe[urgent] 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 » Swing / AWT / SWT
Bookmark "refreshing the jframe[urgent]" Watch "refreshing the jframe[urgent]" New topic
Author

refreshing the jframe[urgent]

netharam ram
Ranch Hand

Joined: Aug 09, 2001
Posts: 202
Hi, I'm using a JFrame containing a JTextarea.I'm displaying the list of files in the specified folder (i.e. appending it to the jtextarea).When the system is processing it does not display the updated containers.Moreover if we switch to some other application & return to it,the jframe is fully blank until the files are completely found.I want to add to the list whenever each file is found & stop it intermediately.Please reply me as soon as possible.
Happy middling with java.
Bye from Netharam.
Jeff Wisard
Ranch Hand

Joined: Jan 07, 2002
Posts: 89
It sounds like you are executing a long process on the same thread that is used to refresh the GUI components in your application. Essentially what you need to do is spawn a new thread to do your file processing for you. This way, the GUI thread is free to perform whatever updates (repaints) that it needs to do without having to wait for your processing to finish.
Spawning a new thread will make it easy for you to also update the data in your components while the processing is happening. For example, if you receive a file name from your process, you can append that to the JTextArea and it will be displayed WHILE your process is off getting the next file name. You can also stop your processing by pressing a button or otherwise interacting with the GUI if you use a thread.
Hope this helps!


Jeff Wisard<br />Sun Certified Java Programmer (Java 2)<br />Sun Certified Web Component Developer
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
Hi,
If you search for "Swing Worker" on the sun site you'll find a very handy implementation of background threads specially designed for swing by people at Sun.
I had similar problems with a data access interface and this worked a treat - and it was easy to drop into event methods too
Hope that helps,


Raising Flares debut album 'Ignition' out now

http://www.raisingflares.com

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
 
jQuery in Action, 2nd edition
 
subject: refreshing the jframe[urgent]
 
Similar Threads
Java Swing and Flash
java project
pkzip
resizing a Jlist's width by the user[urgent]
User Documentation