Java Reference
In-Depth Information
The method showMessageDialog has four parameters, which are described in Table 3-3.
TABLE 3-3 Parameters for the Method showMessageDialog
Parameter
Description
parentComponent
This is an object that represents the parent of the
dialog box. For now, we will specify the
parentComponent to be null , in which case
the program uses a default component that causes
the dialog box to appear in the middle of the
screen. Note that null is a reserved word in Java.
3
messageStringExpression
The messageStringExpression is
evaluated and its value appears in the dialog box.
boxTitleString
The boxTitleString represents the title of
the dialog box.
messageType
An int value representing the type of icon that will
appear in the dialog box. Alternatively, you can use
certain JOptionPane options described below.
Table 3-4 describes the options of the class JOptionPane that can be used with the
parameter messageType . The option name is shown in bold. Examples 3-9 through 3-11
illustrate these options.
TABLE 3-4 JOptionPane Options for the Parameter messageType
messageType
Description
The error icon,
, is displayed in
JOptionPane.ERROR_MESSAGE
the dialog box.
The information icon,
,is
JOptionPane.INFORMATION_MESSAGE
displayed in the dialog box.
JOptionPane.PLAIN_MESSAGE
No icon appears in the dialog box.
The question icon,
, is displayed
JOptionPane.QUESTION_MESSAGE
in the dialog box.
The warning icon,
, is displayed
JOptionPane.WARNING_MESSAGE
in the dialog box.
Search WWH ::




Custom Search