Progress bar in JDialog  
Author Message
sent1729





PostPosted: 2006-2-23 21:49:00 Top

java-programmer, Progress bar in JDialog 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





PostPosted: 2006-2-23 22:09:00 Top

java-programmer >> Progress bar in JDialog <email***@***.com> wrote:
> 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.

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.)

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
Thomas Weidenfeller





PostPosted: 2006-2-24 0:01:00 Top

java-programmer >> Progress bar in JDialog email***@***.com wrote:
> 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
--
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





PostPosted: 2006-2-24 18:39:00 Top

java-programmer >> Progress bar in JDialog On Thu, 23 Feb 2006 21:49:26 +0800, email***@***.com wrote
(in article <email***@***.com>):

> 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
>

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





PostPosted: 2006-2-24 18:40:00 Top

java-programmer >> Progress bar in JDialog On Thu, 23 Feb 2006 21:49:26 +0800, email***@***.com wrote
(in article <email***@***.com>):

> 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
>

sorry i forgot the link

http://java.sun.com/docs/books/tutorial/uiswing/misc/threads.html