Hi all,
I am a new beginner to Java Programming. In my application I am loading
an xml doc in JFrame, while doc is loading I would like to see a
progress bar above the J frame.
This is what I did:
I created a modal JDialog with a progress bar, to be able to show the
dialog above the frame. But if I do that then it freezes the loading of
the xml doc in my Jframe. In other words, only after I close the
JDialog I am able to load the document in my JFrame. Hence, the whole
point of showing a progress bar while loading the document is missed.
How to get over this problem. Can anyone please help.
Any input is greatly appreciated.
Thanks
Nathan
Chris Smith - 23 Feb 2006 14:08 GMT
> This is what I did:
>
[quoted text clipped - 5 lines]
>
> How to get over this problem. Can anyone please help.
If you want to perform long-running tasks in a GUI application, you must
create a new thread to do so. This is true regardless of whether you
use a JProgressBar or not. Simply create and start your new thread
before showing the modal dialog box from the AWT Event Dispatch Thread.
(As always, then, you need to use EventQueue.invokeLater to perform any
GUI work, including updating the value of the progress bar.)

Signature
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.
Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
Thomas Weidenfeller - 23 Feb 2006 16:00 GMT
> I created a modal JDialog with a progress bar, to be able to show the
> dialog above the frame. But if I do that then it freezes the loading of
> the xml doc in my Jframe. In other words, only after I close the
> JDialog I am able to load the document in my JFrame. Hence, the whole
> point of showing a progress bar while loading the document is missed.
See the list of the Top 5 questions in the comp.lang.java.gui FAQ. And
don't forget to start reading Sun's GUI and threading tutorials.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
steve - 24 Feb 2006 10:38 GMT
> Hi all,
>
[quoted text clipped - 16 lines]
> Thanks
> Nathan
welcome to threading.
you also need to ensure you start your gui in the "right" thread, which most
people don't do.
I.E don't just crash aimlessly straight thru your main and into the
xxx.visible(true);
steve - 24 Feb 2006 10:39 GMT
> Hi all,
>
[quoted text clipped - 16 lines]
> Thanks
> Nathan
sorry i forgot the link
http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html