JOptionPane makes it easy to pop up a standard dialog box that
prompts users for a value or informs them of something.
For information about using JOptionPane, see
How to Make Dialogs,
a section in The Java Tutorial.
While the JOptionPane
class may appear complex because of the large number of methods, almost
all uses of this class are one-line calls to one of the static
showXxxDialog methods shown below:
| Method Name | Description |
|---|---|
| showConfirmDialog | Asks a confirming question, like yes/no/cancel. |
| showInputDialog | Prompt for some input. |
| showMessageDialog | Tell the user about something that has happened. |
| showOptionDialog | The Grand Unification of the above three. |
showInternalXXX
flavor, which uses an internal frame to hold the dialog box (see
JInternalFrame).
Multiple convenience methods have also been defined -- overloaded
versions of the basic methods that use different parameter lists.
All dialogs are modal. Each showXxxDialog method blocks
the caller until the user's interaction is complete.
| icon | message |
| input value | |
| option buttons | |
ComponentOrientation property.
Parameters:
The parameters to these methods follow consistent patterns:
- parentComponent
- Defines the
Componentthat is to be the parent of this dialog box. It is used in two ways: theFramethat contains it is used as theFrameparent for the dialog box, and its screen coordinates are used in the placement of the dialog box. In general, the dialog box is placed just below the component. This parameter may benull, in which case a defaultFrameis used as the parent, and the dialog will be centered on the screen (depending on the L&F).- message
- A descriptive message to be placed in the dialog box. In the most common usage, message is just a
StringorStringconstant. However, the type of this parameter is actuallyObject. Its interpretation depends on its type:
- Object[]
- An array of objects is interpreted as a series of messages (one per object) arranged in a vertical stack. The interpretation is recursive -- each object in the array is interpreted according to its type.
- Component
- The
Componentis displayed in the dialog.- Icon
- The
Iconis wrapped in aJLabeland displayed in the dialog.- others
- The object is converted to a
Stringby calling itstoStringmethod. The result is wrapped in aJLabeland displayed.- messageType
- Defines the style of the message. The Look and Feel manager may lay out the dialog differently depending on this value, and will often provide a default icon. The possible values are:
ERROR_MESSAGEINFORMATION_MESSAGEWARNING_MESSAGEQUESTION_MESSAGEPLAIN_MESSAGE- optionType
- Defines the set of option buttons that appear at the bottom of the dialog box:
You aren't limited to this set of option buttons. You can provide any buttons you want using the options parameter.
DEFAULT_OPTIONYES_NO_OPTIONYES_NO_CANCEL_OPTIONOK_CANCEL_OPTION- options
- A more detailed description of the set of option buttons that will appear at the bottom of the dialog box. The usual value for the options parameter is an array of
Strings. But the parameter type is an array ofObjects. A button is created for each object depending on its type:
- Component
- The component is added to the button row directly.
- Icon
- A
JButtonis created with this as its label.- other
- The
Objectis converted to a string using itstoStringmethod and the result is used to label aJButton.- icon
- A decorative icon to be placed in the dialog box. A default value for this is determined by the
messageTypeparameter.- title
- The title for the dialog box.
- initialValue
- The default selection (input value).
When the selection is changed, setValue is invoked,
which generates a PropertyChangeEvent.
If a JOptionPane has configured to all input
setWantsInput
the bound property JOptionPane.INPUT_VALUE_PROPERTY
can also be listened
to, to determine when the user has input or selected a value.
When one of the showXxxDialog methods returns an integer,
the possible values are:
YES_OPTION
NO_OPTION
CANCEL_OPTION
OK_OPTION
CLOSED_OPTION
JOptionPane.showMessageDialog(null, "alert", "alert", JOptionPane.ERROR_MESSAGE);
JOptionPane.showInternalMessageDialog(frame, "information",
"information", JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showConfirmDialog(null,
"choose one", "choose one", JOptionPane.YES_NO_OPTION);
JOptionPane.showInternalConfirmDialog(frame,
"please choose one", "information",
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.INFORMATION_MESSAGE);
Object[] options = { "OK", "CANCEL" };
JOptionPane.showOptionDialog(null, "Click OK to continue", "Warning",
JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,
null, options, options[0]);
String inputValue = JOptionPane.showInputDialog("Please input a value");
Object[] possibleValues = { "First", "Second", "Third" };
Object selectedValue = JOptionPane.showInputDialog(null,
"Choose one", "Input",
JOptionPane.INFORMATION_MESSAGE, null,
possibleValues, possibleValues[0]);
JOptionPane directly, the
standard pattern is roughly as follows:
JOptionPane pane = new JOptionPane(arguments);
pane.set.Xxxx(...); // Configure
JDialog dialog = pane.createDialog(parentComponent, title);
dialog.setVisible(true);
Object selectedValue = pane.getValue();
if(selectedValue == null)
return CLOSED_OPTION;
//If there is not an array of option buttons:
if(options == null) {
if(selectedValue instanceof Integer)
return ((Integer)selectedValue).intValue();
return CLOSED_OPTION;
}
//If there is an array of option buttons:
for(int counter = 0, maxCounter = options.length;
counter < maxCounter; counter++) {
if(options[counter].equals(selectedValue))
return counter;
}
return CLOSED_OPTION;
Warning
Swing is not thread safe. For more information see Swing's Threading Policy.
Warning
Serialized objects of this class will not be compatible with
future Swing releases. The current serialization support is
appropriate for short term storage or RMI between applications running
the same version of Swing. As of 1.4, support for long term storage
of all JavaBeans
has been added to the java.beans package.
Please see java..
JInternalFrame
| Modifier and Type | Class and Description |
|---|---|
| protected class | JOptionPane.
This class implements accessibility support for the
|
| Modifier and Type | Field and Description |
|---|---|
| public static final int | CANCEL_OPTION
Return value from class method if CANCEL is chosen. |
| public static final int | CLOSED_OPTION
Return value from class method if user closes window without selecting
anything, more than likely this should be treated as either a
|
| public static final int | DEFAULT_OPTION
Type meaning Look and Feel should not supply any options -- only
use the options from the |
| public static final int | ERROR_MESSAGE
Used for error messages. |
| protected transient Icon | icon
Icon used in pane. |
| public static final String | ICON_PROPERTY
Bound property name for |
| public static final int | INFORMATION_MESSAGE
Used for information messages. |
| public static final String | INITIAL_SELECTION_VALUE_PROPERTY
Bound property name for |
| public static final String | INITIAL_VALUE_PROPERTY
Bound property name for |
| protected transient Object | initialSelectionValue
Initial value to select in |
| protected transient Object | initialValue
Value that should be initially selected in |
| public static final String | INPUT_VALUE_PROPERTY
Bound property name for |
| protected transient Object | inputValue
Value the user has input. |
| protected transient Object | message
Message to display. |
| public static final String | MESSAGE_PROPERTY
Bound property name for |
| public static final String | MESSAGE_TYPE_PROPERTY
Bound property name for |
| protected int | messageType
Message type. |
| public static final int | NO_OPTION
Return value from class method if NO is chosen. |
| public static final int | OK_CANCEL_OPTION
Type used for |
| public static final int | OK_OPTION
Return value from class method if OK is chosen. |
| public static final String | OPTION_TYPE_PROPERTY
Bound property name for |
| protected transient Object[] | options
Options to display to the user. |
| public static final String | OPTIONS_PROPERTY
Bound property name for |
| protected int | optionType
Option type, one of |
| public static final int | PLAIN_MESSAGE
No icon is used. |
| public static final int | QUESTION_MESSAGE
Used for questions. |
| public static final String | SELECTION_VALUES_PROPERTY
Bound property name for |
| protected transient Object[] | selectionValues
Array of values the user can choose from. |
| private static volatile Frame | |
| private static final String | |
| public static final Object | UNINITIALIZED_VALUE
Indicates that the user has not yet selected a value. |
| protected transient Object | value
Currently selected value, will be a valid option, or
|
| public static final String | VALUE_PROPERTY
Bound property name for |
| public static final String | WANTS_INPUT_PROPERTY
Bound property name for |
| protected boolean | wantsInput
If true, a UI widget will be provided to the user to get input. |
| public static final int | WARNING_MESSAGE
Used for warning messages. |
| public static final int | YES_NO_CANCEL_OPTION
Type used for |
| public static final int | YES_NO_OPTION
Type used for |
| public static final int | YES_OPTION
Return value from class method if YES is chosen. |
| Access | Constructor and Description |
|---|---|
| public | |
| public | JOptionPane(Object
the message)Object to displayCreates a instance of |
| public | JOptionPane(Object
the message, int Object to displaythe type of message to be displayed:
messageType)ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE,
QUESTION_MESSAGE,
or PLAIN_MESSAGECreates an instance of |
| public | JOptionPane(Object
the message, int Object to displaythe type of message to be displayed:
messageType, int ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE,
QUESTION_MESSAGE,
or PLAIN_MESSAGEthe options to display in the pane:
optionType)DEFAULT_OPTION, YES_NO_OPTION,
YES_NO_CANCEL_OPTION,
OK_CANCEL_OPTIONCreates an instance of |
| public | JOptionPane(Object
the message, int Object to displaythe type of message to be displayed:
messageType, int ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE,
QUESTION_MESSAGE,
or PLAIN_MESSAGEthe options to display in the pane:
optionType, Icon DEFAULT_OPTION, YES_NO_OPTION,
YES_NO_CANCEL_OPTION,
OK_CANCEL_OPTIONthe icon)Icon image to displayCreates an instance of |
| public | JOptionPane(Object
the message, int Object to displaythe type of message to be displayed:
messageType, int ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE,
QUESTION_MESSAGE,
or PLAIN_MESSAGEthe options to display in the pane:
optionType, Icon DEFAULT_OPTION,
YES_NO_OPTION,
YES_NO_CANCEL_OPTION,
OK_CANCEL_OPTIONthe icon, Object[] Icon image to displaythe choices the user can select options)Creates an instance of |
| public | JOptionPane(Object
the message, int Object to displaythe type of message to be displayed:
messageType, int ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE,
QUESTION_MESSAGE,
or PLAIN_MESSAGEthe options to display in the pane:
optionType, Icon DEFAULT_OPTION,
YES_NO_OPTION,
YES_NO_CANCEL_OPTION,
OK_CANCEL_OPTIONthe Icon image to display icon, Object[] the choices the user can select options, Object the choice that is initially selected; if
initialValue)null, then nothing will be initially selected;
only meaningful if options is usedCreates an instance of |
| Modifier and Type | Method and Description |
|---|---|
| private static boolean | |
| private static void | |
| private static void | |
| public JDialog | Returns: a newJDialog containing this instancedetermines the frame in which the dialog
is displayed; if the parentComponent, String parentComponent has
no Frame, a default Frame is usedthe title string for the dialog title)Creates and returns a new |
| public JDialog | Returns: a newJDialog containing this instancethe title string for the dialog title)Creates and returns a new parentless |
| private JDialog | |
| public JInternalFrame | Returns: aJInternalFrame containing a
JOptionPanethe parent parentComponent, String Component for
the internal framethe title)String to display in the
frame's title barCreates and returns an instance of |
| public AccessibleContext | Returns: an AccessibleJOptionPane that serves as the AccessibleContext of this AccessibleJOptionPaneOverrides java. Implements javax. Returns the |
| public static JDesktopPane | Returns: theJDesktopPane that contains the component,
or null if the component is null
or does not have an ancestor that is a
JInternalFramethe parentComponent)Component to check for a
desktopReturns the specified component's desktop pane. |
| public static Frame | Returns: theFrame that contains the component,
or getRootFrame
if the component is null,
or does not have a valid Frame parentthe parentComponent)Component to check for a
FrameReturns the specified component's |
| public Icon | |
| public Object | Returns: the initially selected valueReturns the input value that is displayed as initially selected to the user. |
| public Object | |
| public Object | Returns: theObject the user specified,
if it was one of the objects, or a
String if it was a value typed into a
fieldReturns the value the user has input, if |
| public int | Returns: an integer giving the maximum number of characters on a lineReturns the maximum number of characters to place on a line in a message. |
| public Object | |
| public int | |
| public Object[] | Returns: the array ofObjects that give the user's choicesReturns the choices the user can make. |
| public int | Returns: an integer specifying the user-selectable optionsReturns the type of options that are displayed. |
| public static Frame | Returns: the defaultFrame to useReturns the |
| public Object[] | Returns: the array ofObjects the user can selectReturns the input selection values. |
| public OptionPaneUI | Returns: theOptionPaneUI objectOverrides javax. Returns the UI object which implements the L&F; for this component. |
| public String | Returns: the string "OptionPaneUI"Overrides javax. Returns the name of the UI class that implements the L&F; for this component. |
| public Object | Returns: theObject chosen by the user,
UNINITIALIZED_VALUE
if the user has not yet made a choice, or null if
the user closed the window without making a choiceReturns the value the user has selected. |
| public boolean | Returns: true if an input component will be providedReturns the value of the |
| pack-priv static Window | Returns: theFrame or Dialog that
contains the component, or the default
frame if the component is null,
or does not have a valid
Frame or Dialog parentthe parentComponent)Component to check for a
Frame or DialogReturns the specified component's toplevel |
| private void | |
| protected String | Returns: a string representation of thisJOptionPaneOverrides javax. Returns a string representation of this |
| private void | readObject(ObjectInputStream s)
Hides javax. We use the |
| public void | selectInitialValue()
Requests that the initial value be selected, which will set focus to the initial value. |
| public void | |
| public void | setInitialSelectionValue(Object
the initially selected value newValue)Sets the input value that is initially displayed as selected to the user. |
| public void | setInitialValue(Object
the newInitialValue)Object that gets the initial
keyboard focusSets the initial value that is to be enabled -- the
|
| public void | setInputValue(Object
the newValue)Object used to set the
value that the user specified (usually in a text field)Sets the input value that was selected or input by the user. |
| public void | |
| public void | setMessageType(int
an integer specifying the kind of message to display:
newType)ERROR_MESSAGE, INFORMATION_MESSAGE,
WARNING_MESSAGE,
QUESTION_MESSAGE, or PLAIN_MESSAGESets the option pane's message type. |
| public void | setOptions(Object[]
an array of newOptions)Objects that create the
buttons the user can click on, or arbitrary
Components to add to the paneSets the options this pane displays. |
| public void | setOptionType(int
an integer specifying the options the L&F is to display:
newType)DEFAULT_OPTION,
YES_NO_OPTION,
YES_NO_CANCEL_OPTION,
or OK_CANCEL_OPTIONSets the options to display. |
| public static void | setRootFrame(Frame
the default newRootFrame)Frame to useSets the frame to use for class methods in which a frame is not provided. |
| public void | setSelectionValues(Object[]
an array of newValues)Objects the user to be
displayed
(usually in a list or combo-box) from which
the user can make a selectionSets the input selection values for a pane that provides the user with a list of items to choose from. |
| public void | setUI(OptionPaneUI
the ui)OptionPaneUI L&F objectSets the UI object which implements the L&F; for this component. |
| public void | |
| public void | setWantsInput(boolean
if true, an input component whose parent is newValue)parentComponent
is provided to allow the user to input a value.Sets the |
| public static int | Returns: an integer indicating the option selected by the userdetermines the parentComponent, Object Frame in which the
dialog is displayed; if null,
or if the parentComponent has no
Frame, a
default Frame is usedthe message)Object to displayBrings up a dialog with the options Yes, No and Cancel; with the title, Select an Option. |
| public static int | Returns: an int indicating the option selected by the userdetermines the parentComponent, Object Frame in which the
dialog is displayed; if null,
or if the parentComponent has no
Frame, a
default Frame is usedthe message, String Object to displaythe title string for the dialog title, int an int designating the options available on the dialog:
optionType)YES_NO_OPTION,
YES_NO_CANCEL_OPTION,
or OK_CANCEL_OPTIONBrings up a dialog where the number of choices is determined
by the |
| public static int | Returns: an integer indicating the option selected by the userdetermines the parentComponent, Object Frame in
which the dialog is displayed; if null,
or if the parentComponent has no
Frame, a
default Frame is used.the message, String Object to displaythe title string for the dialog title, int an integer designating the options available
on the dialog: optionType, int YES_NO_OPTION,
YES_NO_CANCEL_OPTION,
or OK_CANCEL_OPTIONan integer designating the kind of message this is;
primarily used to determine the icon from the pluggable
Look and Feel: messageType)ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE,
QUESTION_MESSAGE,
or PLAIN_MESSAGEBrings up a dialog where the number of choices is determined
by the |
| public static int | Returns: an int indicating the option selected by the userdetermines the parentComponent, Object Frame in which the
dialog is displayed; if null,
or if the parentComponent has no
Frame, a
default Frame is usedthe Object to display message, String the title string for the dialog title, int an int designating the options available on the dialog:
optionType, int YES_NO_OPTION,
YES_NO_CANCEL_OPTION,
or OK_CANCEL_OPTIONan int designating the kind of message this is,
primarily used to determine the icon from the pluggable
Look and Feel: messageType, Icon ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE,
QUESTION_MESSAGE,
or PLAIN_MESSAGEthe icon to display in the dialog icon)Brings up a dialog with a specified icon, where the number of
choices is determined by the |
| public static String | Returns: user's inputthe message)Object to displayShows a question-message dialog requesting input from the user. |
| public static String | Returns: user's inputthe message, Object Object to displaythe value used to initialize the input
field initialSelectionValue)Shows a question-message dialog requesting input from the user, with
the input value initialized to |
| public static String | Returns: user's inputthe parent parentComponent, Object Component for the
dialogthe message)Object to displayShows a question-message dialog requesting input from the user
parented to |
| public static String | Returns: user's inputthe parent parentComponent, Object Component for the
dialogthe message, Object Object to displaythe value used to initialize the input
field initialSelectionValue)Shows a question-message dialog requesting input from the user and
parented to |
| public static String | Returns: user's inputthe parent parentComponent, Object Component for the
dialogthe message, String Object to displaythe title, int String to display in the dialog
title barthe type of message that is to be displayed:
messageType)ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE,
QUESTION_MESSAGE,
or PLAIN_MESSAGEShows a dialog requesting input from the user parented to
|
| public static Object | Returns: user's input, ornull meaning the user
canceled the inputthe parent parentComponent, Object Component for the
dialogthe message, String Object to displaythe title, int String to display in the
dialog title barthe type of message to be displayed:
messageType, Icon ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE,
QUESTION_MESSAGE,
or PLAIN_MESSAGEthe icon, Object[] Icon image to displayan array of selectionValues, Object Objects that
gives the possible selectionsthe value used to initialize the input
field initialSelectionValue)Prompts the user for input in a blocking dialog where the initial selection, possible selections, and all other options can be specified. |
| public static int | Returns: an integer indicating the option selected by the userdetermines the parentComponent, Object Frame in
which the dialog is displayed; if null,
or if the parentComponent has no
Frame, a default Frame is usedthe message)Object to displayBrings up an internal dialog panel with the options Yes, No and Cancel; with the title, Select an Option. |
| public static int | Returns: an integer indicating the option selected by the userdetermines the parentComponent, Object Frame
in which the dialog is displayed; if null,
or if the parentComponent has no
Frame, a default Frame is usedthe object to display in the dialog; a
message, String Component object is rendered as a
Component; a String
object is rendered as a string; other objects
are converted to a String using the
toString methodthe title string for the dialog title, int an integer designating the options
available on the dialog: optionType)YES_NO_OPTION,
or YES_NO_CANCEL_OPTIONBrings up a internal dialog panel where the number of choices
is determined by the |
| public static int | Returns: an integer indicating the option selected by the userdetermines the parentComponent, Object Frame in
which the dialog is displayed; if null,
or if the parentComponent has no
Frame, a default Frame is usedthe object to display in the dialog; a
message, String Component object is rendered as a
Component; a String
object is rendered as a string; other objects are
converted to a String using the
toString methodthe title string for the dialog title, int an integer designating the options
available on the dialog:
optionType, int YES_NO_OPTION, or YES_NO_CANCEL_OPTIONan integer designating the kind of message this is,
primarily used to determine the icon from the
pluggable Look and Feel: messageType)ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE, QUESTION_MESSAGE,
or PLAIN_MESSAGEBrings up an internal dialog panel where the number of choices
is determined by the |
| public static int | Returns: an integer indicating the option selected by the userdetermines the parentComponent, Object Frame
in which the dialog is displayed; if null,
or if the parentComponent has no Frame, a
default Frame is usedthe object to display in the dialog; a
message, String Component object is rendered as a
Component; a String
object is rendered as a string; other objects are
converted to a String using the
toString methodthe title string for the dialog title, int an integer designating the options available
on the dialog:
optionType, int YES_NO_OPTION, or
YES_NO_CANCEL_OPTION.an integer designating the kind of message this is,
primarily used to determine the icon from the pluggable
Look and Feel: messageType, Icon ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE, QUESTION_MESSAGE,
or PLAIN_MESSAGEthe icon to display in the dialog icon)Brings up an internal dialog panel with a specified icon, where
the number of choices is determined by the |
| public static String | Returns: user's inputthe parent parentComponent, Object Component
for the dialogthe message)Object to displayShows an internal question-message dialog requesting input from
the user parented to |
| public static String | Returns: user's inputthe parent parentComponent, Object Component for the dialogthe message, String Object to displaythe title, int String to display in the
dialog title barthe type of message that is to be displayed:
ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE,
QUESTION_MESSAGE, or PLAIN_MESSAGE messageType)Shows an internal dialog requesting input from the user parented
to |
| public static Object | Returns: user's input, ornull meaning the user
canceled the inputthe parent parentComponent, Object Component for the dialogthe message, String Object to displaythe title, int String to display in the dialog
title barthe type of message to be displayed:
messageType, Icon ERROR_MESSAGE, INFORMATION_MESSAGE,
WARNING_MESSAGE,
QUESTION_MESSAGE, or PLAIN_MESSAGEthe icon, Object[] Icon image to displayan array of selectionValues, Object Objects that
gives the possible selectionsthe value used to initialize the input
field initialSelectionValue)Prompts the user for input in a blocking internal dialog where the initial selection, possible selections, and all other options can be specified. |
| public static void | showInternalMessageDialog(Component
determines the parentComponent, Object Frame
in which the dialog is displayed; if null,
or if the parentComponent has no
Frame, a default Frame is usedthe object to display message)Brings up an internal confirmation dialog panel. |
| public static void | showInternalMessageDialog(Component
determines the parentComponent, Object Frame
in which the dialog is displayed; if null,
or if the parentComponent has no
Frame, a default Frame is usedthe message, String Object to displaythe title string for the dialog title, int the type of message to be displayed:
messageType)ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE,
QUESTION_MESSAGE,
or PLAIN_MESSAGEBrings up an internal dialog panel that displays a message
using a default icon determined by the |
| public static void | showInternalMessageDialog(Component
determines the parentComponent, Object Frame
in which the dialog is displayed; if null,
or if the parentComponent has no
Frame, a default Frame is usedthe message, String Object to displaythe title string for the dialog title, int the type of message to be displayed:
messageType, Icon ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE,
QUESTION_MESSAGE,
or PLAIN_MESSAGEan icon to display in the dialog that helps the user
identify the kind of message that is being displayed icon)Brings up an internal dialog panel displaying a message, specifying all parameters. |
| public static int | Returns: an integer indicating the option chosen by the user, orCLOSED_OPTION if the user closed the Dialogdetermines the parentComponent, Object Frame
in which the dialog is displayed; if null,
or if the parentComponent has no
Frame, a default Frame is usedthe object to display in the dialog; a
message, String Component object is rendered as a
Component; a String
object is rendered as a string. Other objects are
converted to a String using the
toString methodthe title string for the dialog title, int an integer designating the options available
on the dialog: optionType, int YES_NO_OPTION,
or YES_NO_CANCEL_OPTIONan integer designating the kind of message this is;
primarily used to determine the icon from the
pluggable Look and Feel: messageType, Icon ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE, QUESTION_MESSAGE,
or PLAIN_MESSAGEthe icon to display in the dialog icon, Object[] an array of objects indicating the possible choices
the user can make; if the objects are components, they
are rendered properly; non- options, Object String
objects are rendered using their toString
methods; if this parameter is null,
the options are determined by the Look and Feelthe object that represents the default selection
for the dialog; only meaningful if initialValue)options
is used; can be nullBrings up an internal dialog panel with a specified icon, where
the initial choice is determined by the |
| public static void | showMessageDialog(Component
determines the parentComponent, Object Frame in
which the dialog is displayed; if null,
or if the parentComponent has no
Frame, a default Frame is usedthe message)Object to displayBrings up an information-message dialog titled "Message". |
| public static void | showMessageDialog(Component
determines the parentComponent, Object Frame
in which the dialog is displayed; if null,
or if the parentComponent has no
Frame, a default Frame is usedthe message, String Object to displaythe title string for the dialog title, int the type of message to be displayed:
messageType)ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE,
QUESTION_MESSAGE,
or PLAIN_MESSAGEBrings up a dialog that displays a message using a default
icon determined by the |
| public static void | showMessageDialog(Component
determines the parentComponent, Object Frame in which the
dialog is displayed; if null,
or if the parentComponent has no
Frame, a
default Frame is usedthe message, String Object to displaythe title string for the dialog title, int the type of message to be displayed:
messageType, Icon ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE,
QUESTION_MESSAGE,
or PLAIN_MESSAGEan icon to display in the dialog that helps the user
identify the kind of message that is being displayed icon)Brings up a dialog displaying a message, specifying all parameters. |
| public static int | Returns: an integer indicating the option chosen by the user, orCLOSED_OPTION if the user closed
the dialogdetermines the parentComponent, Object Frame
in which the dialog is displayed; if
null, or if the
parentComponent has no
Frame, a
default Frame is usedthe message, String Object to displaythe title string for the dialog title, int an integer designating the options available on the
dialog: optionType, int DEFAULT_OPTION,
YES_NO_OPTION,
YES_NO_CANCEL_OPTION,
or OK_CANCEL_OPTIONan integer designating the kind of message this is,
primarily used to determine the icon from the
pluggable Look and Feel: messageType, Icon ERROR_MESSAGE,
INFORMATION_MESSAGE,
WARNING_MESSAGE,
QUESTION_MESSAGE,
or PLAIN_MESSAGEthe icon to display in the dialog icon, Object[] an array of objects indicating the possible choices
the user can make; if the objects are components, they
are rendered properly; non- options, Object String
objects are
rendered using their toString methods;
if this parameter is null,
the options are determined by the Look and Feelthe object that represents the default selection
for the dialog; only meaningful if initialValue)options
is used; can be nullBrings up a dialog with a specified icon, where the initial
choice is determined by the |
| private static int | |
| public void | updateUI()
Overrides javax. Notification from the |
| private void | writeObject(ObjectOutputStream s)
Hides javax. Before writing a |