Solved

modal/non-modal dialog boxes

Posted on 2001-08-23
6
344 Views
Last Modified: 2010-08-05
I am trying to create a JDialog box that has a progress bar, to show the progress of an operation on the window below.  If I create a modal dialog box, The box shows up correctly, but has taken processing away from the window below, which cannot complete its operation until the window is closed.

On the other hand, if I create a non-modal window, the dialog is displayed only showing the title correctly, with a blank content area.  When it is done this way, the operation completes, but the progress bar cannot be seen.

The code in the actionListener for the underlying window that is supposed to display the dialog looks something like:
QSGBS.waitDialog = new GUI.WaitDialog(new java.awt.Frame(), false, "Please Wait While Searching for Bookings...");
QSGBS.waitDialog.show();
QSGBS.monthlyPlanner.displayMonthlyBookings(cal); //operation on underlying window
QSGBS.waitDialog.dispose();

Can anybody help??
0
Comment
Question by:steeks
6 Comments
 
LVL 6

Expert Comment

by:kotan
ID: 6416524
You can use Progress monitor to pop up dialog box with progress bar.

http://java.sun.com/docs/books/tutorial/uiswing/components/progress.html#monitors
0
 
LVL 9

Expert Comment

by:yongsing
ID: 6416531
You can use the javax.swing.Timer class to do that. See tutorial:

http://java.sun.com/docs/books/tutorial/uiswing/misc/timer.html
0
 
LVL 1

Author Comment

by:steeks
ID: 6416642
I tried to use the progress monitor, but the same thing happened.

What I'm actually doing is querying a database, to display the results in a monthly calender.  The program initially searches the database for bookings, and the progress bar works fine.  When a button on the calendar is pressed to change year/month, the program then searches for bookings again.  For some strange reason, when it goes to do this, you get a blank progress dialog that shows nothing.
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 92

Expert Comment

by:objects
ID: 6416645
You need to handle your processing and your dialog in seperate threads. As you've noticed and stated it's pointless performing your processing AFTER your dialog has been closed.
0
 
LVL 92

Expert Comment

by:objects
ID: 6416675
Additionally you should not be doing lengthy processing in the event dispatch thread. This will cause your gui to freeze until the processing is complete.
This is why you're getting blank windows, as no repainting can happen until your processing is completed.
0
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 6416679
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
The viewer will learn how to implement Singleton Design Pattern in Java.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question