Java Reference
In-Depth Information
The javax.swing package contains JOptionPane , a class that "makes it easy to pop up a
standard dialog box," according to the class comment.
For example, the following code displays and redisplays a dialog until the user clicks the Yes
button (see Figure 4.5):
package com.oozinoz.applications;
import javax.swing.*;
public class ShowOptionPane
{
public static void main(String[] args)
{
int option;
do
{
option =
JOptionPane.showConfirmDialog(
null,
"Had enough?",
" A Stubborn Dialog",
JOptionPane.YES_NO_OPTION);
}
while (option == JOptionPane.NO_OPTION);
}
}
Figure 4.5. The JOptionPane class makes it easy to display dialogs such as this one.
CHALLENGE 4.3
The JOptionPane does in fact make it easy to display a dialog. State whether this
class is a facade, a utility, or a demo, and justify your answer.
CHALLENGE 4.4
Few facades appear in the Java class libraries. Why is that?
Search WWH ::




Custom Search