// File: TestAwt7.java (Module 9) // // Author: Rahul Simha // Created: October 13, 1998 // // Showing the inset problem. import java.awt.*; class NewFrame extends Frame { int width, height; // Constructors. public NewFrame (int width, int height) { // Set the title and other parameters. this.setTitle ("Inset problem"); this.setResizable (true); this.setBackground (Color.cyan); this.setSize (width, height); this.width = width; this.height = height; // Show the frame. this.setVisible (true); } // No-parameter constructor - use a default size. public NewFrame () { this (500, 300); } // Override paint(): public void paint (Graphics g) { // Draw circles of diameter 100 at each corner. // Topleft at 0,0: g.drawOval (0,0, 100,100); // Topleft at (0, height-100): g.drawOval (0, height-100, 100,100); // Topleft at (width-100, 0): g.drawOval (width-100, 0, 100,100); // Topleft at (width-100, width-100): g.drawOval (width-100, height-100, 100,100); } } public class TestAwt7 { public static void main (String[] argv) { NewFrame nf = new NewFrame (300, 300); } }