Java Reference
In-Depth Information
The result of a call is as follows: If the user hits the cancel button, null is
the result. If the user clicks the OK button, the result is the contents of the text
field.
Function showConfirmDialog
Function JOptionPane.showConfirmDialog displays a modal dialog win-
dow with a message and returns an int , depending on what button was clicked.
An example window appears to the right in Fig. 17.19.
We explain only the version that has five parameters. Here they are:
Activity
17-5.2
1. The parent (as with method showMessageDialog ).
2. The message. In the example, it is "Are you a vegetarian?" .
3. The title. In the example, it is: "question message" .
4. Description of the buttons that appear in window. In the example, con-
stant JOptionPane.YES_NO_CANCEL_OPTION was used. Here are the pos-
sible constants:
JOptionPane. YES_NO_OPTION
JOptionPane. YES_NO_CANCEL_OPTION
JOptionPane. OK_CANCEL_OPTION
JOptionPane. DEFAULT_OPTION (gives a single button, OK )
5. The style of the window, which tells what picture to put in the window.
This is one of the following JOptionPane constants:
JOptionPane. ERROR_MESSAGE
JOptionPane. INFORMATION_MESSAGE
JOptionPane. WARNING_MESSAGE
JOptionPane. QUESTION_MESSAGE
JOptionPane. PLAIN_MESSAGE
The result of a call is one of the following JOptionPane constants:
JOptionPane. YES_OPTION
JOptionPane. NO_OPTION
JOptionPane. CANCEL_OPTION
JOptionPane. OK_OPTION
JOptionPane. CLOSED_OPTION
Function showOptionDialog
Function JOptionPane.showOptionDialog displays a modal dialog win-
dow with a message and returns an int , depending on what button was clicked.
The caller gives the buttons that appear in the window. An example dialog win-
dow appears in Fig. 17.20.
We explain the version of the function that has these seven parameters:
Activity
17-5.2
1. The parent (as with method showMessageDialog ).
Search WWH ::




Custom Search