As we have briefly mentioned already there are several show...Dialog() methods that can be used to display a dialog. Briefly these are:
showInputDialog() methods
public static String showInputDialog( Object message ) public static String showInputDialog( Component parentComponent, Object message ) public static String showInputDialog( Component parentComponent, Object message, String title, int messageType ) public static Object showInputDialog( Component parentComponent, Object message, String title, int messageType, Icon icon, Object selectionValues[], Object initialSelectionValue ) public static String showInternalInputDialog( Component parentComponent, Object message ) public static String showInternalInputDialog( Component parentComponent, Object message, String title, int messageType) public static Object showInternalInputDialog( Component parentComponent, Object message, String title, int messageType, Icon icon, Object selectionValues[], Object initialSelectionValue )
The methods in this group create and display an option pane instance that accepts input from the user. Input can come from a default input component, such as a text field, or from a combo box.
showMessageDialog() methods
public static void showMessageDialog( Component parentComponent, Object message ) public static void showMessageDialog( Component parentComponent, Object message, String title, int messageType ) public static void showMessageDialog(Component parentComponent, Object message, String title, int messageType, Icon icon) public static void showInternalMessageDialog( Component parentComponent, Object message ) public static void showInternalMessageDialog( Component parentComponent, Object message, String title, int messageType ) public static void showInternalMessageDialog( Component parentComponent, Object message, String title, int messageType, Icon icon )
This group of methods displays instances of simple message dialog boxes. They can contain an icon and message text, but do not accept input from the user. This type of option pane is typically used to display status information to the user, usually requiring only an OK acknowledgement.
showConfirmDialog() methods
public static int showConfirmDialog( Component parentComponent, Object message ) public static int showConfirmDialog( Component parentComponent, Object message, String title, int optionType ) 258 CHAPTER 8 Dialogs and internal frames public static int showConfirmDialog( Component parentComponent, Object message, String title, int optionType, int messageType ) public static int showConfirmDialog( Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon ) public static int showInternalConfirmDialog( Component parentComponent, Object message ) public static int showInternalConfirmDialog( Component parentComponent, Object message, String title, int optionType ) public static int showInternalConfirmDialog( Component parentComponent, Object message, String title, int optionType, int messageType ) public static int showInternalConfirmDialog( Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon )
The methods in this group create and display instances of a JOptionPane to confirm user selections. This type of option pane is generally used to prompt the user to answer a Yes or No type question (also, OK or Cancel).
showOptionDialog() methods
public static int showOptionDialog( Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon, Object options[], Object initialValue ) public static int showInternalOptionDialog( Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon, Object options[], Object initialValue )
The two methods in this group display option panes containing user selectable options. This is typically useful in situations where the user will select one of several options from a combo box.
Various component area access methods
public void setMessage( Object newMessage ) public Object getMessage() public void setIcon( Icon newIcon ) public Icon getIcon() public void setValue( Object newValue ) public Object getValue() public void setOptions( Object newOptions[] ) public Object[] getOptions() public void setInitialValue( Object newInitialValue ) public Object getInitialValue() public void setMessageType( int newType ) public int getMessageType() public void setOptionType( int newType ) public int getOptionType() public void setSelectionValues( Object newValues[] ) public Object[] getSelectionValues() public void setInitialSelectionValue( Object newValue ) public Object getInitialSelectionValue() public void setInputValue( Object newValue ) public Object getInputValue() public void selectInitialValue()
This group of methods is used to control and access the various component areas within the option pane. For example, the icon can be controlled, or option values can be loaded into the input area, and subsequent selections by the user can be detected and returned.
input to dialogs
public void setWantsInput( boolean newValue ) public boolean getWantsInput()
These methods control and determine whether the user needs to input some information. If so, the option pane will provide a component into which the user can either type text, or from which he or she can select one of several options.