// File: TestAwt5.java (Module 9) // // Author: Rahul Simha // Created: October 13, 1998 // // Geometric figures. import java.awt.*; // Extend Frame in order to override paint() class NewFrame extends Frame { // Override paint(): public void paint (Graphics g) { // Draw a Square: g.drawRect (50,50,50,50); g.drawString ("Square", 50, 115); // Circle: g.drawOval (200,50,50,50); g.drawString ("Circle", 200, 115); // Rounded rectangle: g.drawRoundRect (350,50,75,50,20,20); g.drawString ("Rectangle", 350, 115); // Draw a line across the middle: g.drawLine (0,150,500,150); // Now draw some filled shapes: // Square: g.fillRect (50,200,50,50); g.drawString ("Square", 50, 265); // Circle: g.fillOval (200,200,50,50); g.drawString ("Circle", 200, 265); // Rounded rectangle: g.fillRoundRect (350,200,75,50,20,20); g.drawString ("Rectangle", 350, 265); } } public class TestAwt5 { public static void main (String[] argv) { // Create an instance of NewFrame NewFrame nf = new NewFrame (); // Set the title and other parameters. nf.setTitle ("Some Geometric Figures"); nf.setResizable (true); nf.setBackground (Color.cyan); nf.setSize (500, 300); // Show the frame. nf.setVisible (true); } }