Solved

modal/non-modal dialog boxes

Posted on 2001-08-23
6
345 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…

860 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