Source Code Listing 679
• RandomStringsApplet.java, from Section 6.3, shows 25 copies of the string “Java!” (or
some other string specified in an applet param) in random colors and fonts. The applet
uses RandomStringsPanel.java for its content pane, and there is a stand-alone application
RandomStringsApp.java that uses the same panel class.
• ClickableRandomStringsApp.java, from Section 6.4, is similar to RandomStringsApp.java
except that the window is repainted when the user clicks the window. This is a first exam-
ple of using a mouse listener. The applet version is ClickableRandomStringsApplet.java.
• SimpleStamper.java, from Section 6.4, lets the user place rectangles and ovals on a drawing
area by clicking with the mouse. The applet version is SimpleStamperApplet.java. Both
versions use SimpleStamperPanel.java for their content panes.
• SimpleTrackMouse.java, from Section 6.4, shows information about mouse events. The
applet version is SimpleTrackMouseApplet.java. Both versions use SimpleTrackMousePa-
nel.java for their content panes.
• SimplePaint.java, from Section 6.4, lets the user draw curves in a drawing area and select
the drawing color from a palette. The class SimplePaint can be used either as as applet or
as a stand-alone application.
• RandomArtPanel.java, from Section 6.5, shows a new random “artwork” every four sec-
onds. This is an example of using a Timer. Used in an applet version of the program,
RandomArtApplet.java, and a stand-alone application version, RandomArt.java.
• KeyboardAndFocusDemo.java, from Section 6.5, shows how to use keyboard and focus
events. This class can be run either has an applet or as a stand-alone application.
• SubKillerPanel.java, from Section 6.5, lets the user play a simple game. Uses a timer as
well as keyboard and focus events. The applet version is SubKillerApplet.java, and the
stand-alone application version is SubKiller.java.
• SliderDemo.java, a simple demo from Section 6.6, is an applet that shows three JSlider s.
• TextAreaDemo.java, from Section 6.6, is an applet that demonstrates a JTextArea in a
JScrollPane.
• BorderDemo.java, from Section 6.7, a very simple applet that demonstrates six types of
border.
• SliderAndComboBoxDemo.java, from Section 6.7, shows how to create several components
and lay them out in a GridLayout. Can be used either as an applet or as a stand-alone
application.
• SimpleCalc.java, from Section 6.7, lets the user add, subtract, multiply, or divide two num-
bers input by the user. A demo of text fields, buttons, and layout with nested subpanels.
Can be used either as an applet or as a stand-alone application.
• NullLayoutDemo.java, from Section 6.7, shows how to lay out the components in a con-
tainer for which the layout manager has been set to null. Can be used either as an applet
or as a stand-alone application.
• HighLowGUI.java, from Section 6.7, is a GUI version of HighLow.java, a game where the
user sees a playing card and guesses whether the next card will be higher or lower in value.
This program also requires Card.java, Hand.java, and Deck.java. Can be used as a stand-
alone application and also contains a nested class HighLowGUI.Applet that represents the
applet version of the program
• MosaicDrawController.java, from Section 6.8, demonstrates menus and a color chooser
dialog. This is used in a program where the user colors the squares of a mosaic by