Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Progress bar in JDialog

Thread view: 
sent1729@yahoo.com - 23 Feb 2006 13:49 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.