Java Reference
In-Depth Information
tests if Copy
command
clicked
code to copy
display to
clipboard
tests if Paste
command
clicked
code to paste
data from
clipboard
FIGURE 6-25
The class, Throwable , in line 164 is the superclass of all errors and
exceptions in the Java language, used in this case to generically catch any
exception that might occur. Only objects that are instances of this class (or one
of its subclasses) are thrown by the Java Virtual Machine or can be thrown by
the Java throw statement. Similarly, only this class or one of its subclasses can
be the argument type in a catch clause. For example, NumberFormatException
is a subclass of Throwable.
Searching for the About Calculator Command
According to the requirements document in Figure 6-2 on page 382, if the
user clicks the About Calculator command on the About menu, the program
should display a message box with information about the program.
Figure 6-26 displays the code to search for the About Calculator command.
In line 172, a message is created and stored. Line 173 displays the message in a
message box using the showMessageDialog() method.
170
if ( arg == "About" )
171
{
172
String message =
"Calculator ver. 1.0\nOpenExhibit Software\nCopyright 2007\nAll rights reserved" ;
173
JOptionPane.showMessageDialog ( null ,message, "About Calculator" , JOptionPane.
INFORMATION_MESSAGE ) ;
174
}
175
FIGURE 6-26
The step on the next page enters the code to determine if the user clicked the
About Calculator command on the About menu.
 
Search WWH ::




Custom Search