Java Reference
In-Depth Information
To Enter Code to Create Swing Dialog Boxes
1. Select line 36. Type the new code from Table 3-14.
2. Select lines 26 and 27. Type the new code from Table 3-14.
3. Select lines 23 and 24. Type the new code from Table 3-14.
The code to create Swing dialog boxes is displayed (Figure 3-31). Your code
may wrap differently.
showInputDialog()
methods to
display input
dialog boxes
prompts replaced
by JOptionPane
methods to
create Swing
dialog boxes
FIGURE 3-31
showMessageDialog()
method to display
output message box
Closing Programs That Use Swing
One more line of code is necessary in order to close programs that use
Swing dialog boxes, after the program ends. The System class provides an exit()
method , which is used to terminate an application that displays a graphical user
interface, such as a dialog box. The method accepts an integer argument that
serves as a status code. A 0 (zero) indicates that the application has terminated
successfully. A value of 1 typically indicates abnormal termination. If you do not
include a System.exit(0); statement at the end of the program code, the
command prompt window will not close at the end of the program.
 
Search WWH ::




Custom Search