Java Reference
In-Depth Information
2. One at a time, select lines 40, 38, 24, and 20 and then press the DELETE
key to delete each line.
The TextPad coding window displays the program code, with the unneces-
sary code deleted (Figure 3-29).
FIGURE 3-29
Creating Swing Dialog Boxes
The Swing JOptionPane class provides many methods that make it easy for
programmers to display standard dialog boxes, including methods to show a
confirmation, input, or message dialog box. Table 3-11 shows the basic syntax
of any JOptionPane method. Table 3-12 displays some of the show methods
associated with the JOptionPane class of dialog boxes.
Table 3-11
JOptionPane Methods
General form:
JOptionPane.method(arguments)
Purpose:
To create a dialog box on the screen
Examples:
1. String answer = JOptionPane.showInputDialog("What is your name?");
2. JOptionPane.showMessageDialog(null, "It's been a pleasure to serve
you", "Thank You Box", JOptionPane.PLAIN_MESSAGE);
3. JOptionPane.showConfirmDialog(null, "Please choose one", "Confirm
Box", JOptionPane.YES_NO_OPTION);
 
Search WWH ::




Custom Search