RandomColorGrid - /* An applet that displays four randomly...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
/* An applet that displays four randomly colored rectangles. Each rectangle is a canvas belonging to the class ColorSwatchCanvas. Every so often, a thread picks one of the canvasses at random and changes its color. The user can change the color of one of the canvasses by clicking on it. This file is meant to demonstrate nested classes and anonymous classes. The thread belongs to the class, Runner, which is a nested class inside the RandomColorGrid class. The MouseListeners that respond to user clicks belong to an anonymous class. See the constructor in the ColorSwatchCanvas class. (This file defines both the RandomColorGrid class and ColorSwatchCanvas classes. If you complile this file, you get 4 class files: RandomColorGrid.class, ColorSwatchCanvas.class, RandomColorGrid$Runner.class, and ColorSwatchCanvas$1.class. The latter two class files are the nested classes.) David Eck August 12, 1998 */ * import java.awt.*; import java.awt.event.*; import java.applet.Applet; i public class RandomColorGrid extends Applet {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 3

RandomColorGrid - /* An applet that displays four randomly...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online