?
Solved

Creating a dialog box

Posted on 2006-03-20
9
Medium Priority
?
220 Views
Last Modified: 2010-03-31
Hi Experts

I am trying to create a dialog box that displays an information message on the screen (i.e. one that does not need the user to react to it, or close it, or click on anything), but which also lets the program continue in the background. I have been able to create dialog boxes before but they always need the user to either close the window or click on a button and will suspend the program until the get a response.

I'm after something simple like this:

informationbox.open("I'm doing (whatever it is)");
Do the process
informationbox.close();

All the sites I have gone to explain how to create dialog boxes but this not what I want. Any suggestions?

0
Comment
Question by:zaphod_beeblebrox
9 Comments
 
LVL 10

Expert Comment

by:radarsh
ID: 16234303
JOptionPane.showMessageDialog should be used

________
radarsh
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16234308
JDialog d = new JDialog(yourFrame);
d.setModel(false);
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 400 total points
ID: 16234309
>>d.setModel(false);


should be

d.setModal(false);
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 16234325
   JOptionPane pane = new JOptionPane(message);
    JDialog dialog = pane.createDialog(parentComponent, title);
    dialog.setModel(false);
    dialog.setVisible(true);

    // do your stuff

    dialog.setVisible(false);
0
 
LVL 92

Assisted Solution

by:objects
objects earned 200 total points
ID: 16234328
that'll teach me to cut/paste code without checking it for erroers :-D

   JOptionPane pane = new JOptionPane(message);
    JDialog dialog = pane.createDialog(parentComponent, title);
    dialog.setModal(false);
    dialog.setVisible(true);

    // do your stuff

    dialog.setVisible(false);
0
 

Author Comment

by:zaphod_beeblebrox
ID: 16234386
Thanks CEHJ and Objects both excellent answers. I did not believe how simple it was -- just make the dialog box non modal!!!

Works great thanks again guys for your most excellent answers
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16234387
:-)
0
 
LVL 1

Expert Comment

by:sriki77
ID: 16234393
Hi zaphod_beeblebrox,

I am not sure whether you can do this:

You can activate the GlassPane of your component, instead of showing a dialog box. Place you message on the glasspane. Actvitating the glasspane is like showing a splash screen in the application, application runs and user input is blocked. Once the application finishes its job, hide the glasspane. All the user input consumed by the glasspane is directed to the application.

yourcomponent.getRootPane().getGlassPane().setVisible(true);
//the application does the required work
yourcomponent.getRootPane().getGlassPane().setVisible(false);

Have a look at this link from the java tutorial: http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html

Cheers!
0
 
LVL 92

Expert Comment

by:objects
ID: 16234401
glad I could help :)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month16 days, 1 hour left to enroll

850 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