Java Reference
In-Depth Information
LISTING 4.7
continued
//-----------------------------------------------------------------
// Presents a collection of circles.
//-----------------------------------------------------------------
public static void main (String[] args)
{
JFrame frame = new JFrame ("Splat");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add( new SplatPanel());
frame.pack();
frame.setVisible( true );
}
}
DISPLAY
program simply draws a few filled circles. The interesting thing about this pro-
gram is not what it does, but how it does it—each circle drawn in this program is
represented by its own object.
The main method instantiates a SplatPanel object and adds it to the frame.
The SplatPanel class is shown in Listing 4.8. Like the SmilingFacePanel class
in the previous example, the SplatPanel class is derived from JPanel . It holds as
instance data five Circle objects, which are instantiated in the constructor.
 
Search WWH ::




Custom Search