Solved

modal/non-modal dialog boxes

Posted on 2001-08-23
6
341 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
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…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now