Progress bar in JDialog

S

sent1729

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
 
C

Chris Smith

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
 
T

Thomas Weidenfeller

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
 
S

steve

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);
 
S

steve

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top