zaphod_beeblebrox
asked on
Creating a dialog box
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?
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?
JDialog d = new JDialog(yourFrame);
d.setModel(false);
d.setModel(false);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
JOptionPane pane = new JOptionPane(message);
JDialog dialog = pane.createDialog(parentCo mponent, title);
dialog.setModel(false);
dialog.setVisible(true);
// do your stuff
dialog.setVisible(false);
JDialog dialog = pane.createDialog(parentCo
dialog.setModel(false);
dialog.setVisible(true);
// do your stuff
dialog.setVisible(false);
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
Works great thanks again guys for your most excellent answers
:-)
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( ).getGlass Pane().set Visible(tr ue);
//the application does the required work
yourcomponent.getRootPane( ).getGlass Pane().set Visible(fa lse);
Have a look at this link from the java tutorial: http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html
Cheers!
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(
//the application does the required work
yourcomponent.getRootPane(
Have a look at this link from the java tutorial: http://java.sun.com/docs/books/tutorial/uiswing/components/rootpane.html
Cheers!
glad I could help :)
________
radarsh