Page 131 - Introduction to Programming with Java: A Problem Solving Approach
P. 131

                3.24 GUI Track: Input and Output with JOptionPane (Optional) 97 center of the screen. To go with the default position, specify null for the first argument. The second argu-
ment specifies the message that appears in the dialog box.
Input Dialog Box
Note that a dialog box is often referred to simply as a dialog. Both terms are acceptable. There are several types of JOptionPane dialogs. We consider two of them—the message dialog for output and the input di- alog for input. We’ve already described the message dialog. That’s what showMessageDialog produces. We’ll now look at the input dialog.
The input dialog displays a prompt message and an input box. The top four dialogs in Figure 3.18 are input dialogs. These display a question mark icon as a visual cue that the dialog is asking a question and waiting for user input. Clicking OK processses the value entered. Clicking Cancel closes the dialog box without processing.
 1. Initial display
   prompt message
input box
Apago PDF Enhancer
    2. After entering “painting, dogs playing poker”
3. After clicking OK and entering 42.22
  4. After clicking OK and entering 2 5. After clicking OK
  Figure 3.18 Sample session for PrintPOGUI program






















































































   129   130   131   132   133