Java: Dialogs
There are several ways to build dialog boxes:
JOptionPane - Simple Dialogs
- This is a very easy way (one statement) to build simple dialogs. Usually this, JFileChooser, and maybe JColorChooser are the only dialog classes that you need.
JFileChooser
- This will create and control a standard file chooser dialog.
javax.swing.JColorChooser
- You can call one static method (
Color.showDialog(. . .)
) to display a dialog that lets the user choose a color, or you can add listeners to make a more complicated dialog interaction, or you can use this class to create a color chooser pane. javax.swing.JDialog
- This can be used for building dialogs that are too complicated for JOptionPane.
Dialogs are attached to window (frame)
Every dialog is attached to a window (frame). When the window in iconified, the dialog will automatically disappear, and it will automatically reappear when the window is deiconified. When the window is destroyed, the dialog will disappear.
Dialogs are usually modal
When a dialog in active, input to other parts of the graphical user interface will be blocked. This kind of dialog is called a modal dialog. If you want a dialog which is modeless (allows interaction with other windows), you must use the JDialog class.
Future?
When will Java have a date picker dialog.
Webliography
- Creating Wizard Dialogs with Java Swing (http://java.sun.com/developer/technicalArticles/GUI/swing/wizard/index.html).