// File: ex3.java (Module 9b) // // Author: Rahul Simha // Created: October 14, 2000 // // Template for Ex. 9.3 (Draw a chessboard that re-sizes). import java.awt.*; import javax.swing.*; // Create a JPanel subclass to override paintComponent() class NewPanel extends JPanel { public NewPanel () { this.setBackground (Color.cyan); } // PUT YOUR CODE HERE } class NewFrame extends JFrame { // Constructors. public NewFrame (int width, int height) { // Set the title and other parameters. this.setTitle ("Chessboard"); this.setResizable (true); this.setSize (width, height); // Create panel and add it. this.getContentPane().add (new NewPanel()); // Show the frame. this.setVisible (true); } // No-parameter constructor - use a default size. public NewFrame () { this (500, 300); } } public class ex2 { public static void main (String[] argv) { NewFrame f = new NewFrame (500, 300); } }