// File: TestAwt17.java (Module 9) // // Author: Rahul Simha // Created: October 21, 1998 // // A simple quit button - using paint (the wrong way). import java.awt.*; class NewFrame extends Frame { // Constructor. public NewFrame (int width, int height) { // Set the title and other frame parameters. this.setTitle ("Button example"); this.setResizable (true); this.setBackground (Color.cyan); this.setSize (width, height); // Show the frame. this.setVisible (true); } public void paint (Graphics g) { // Create a Button instance and pass the button // label as a parameter to the constructor. Button b = new Button ("Quit"); // Set the layout manager for our Frame. this.setLayout (new BorderLayout()); // Add the button to the frame. this.add (b); // Call validate to reset: this.validate(); } } // End of class "NewFrame" public class TestAwt17 { public static void main (String[] argv) { NewFrame nf = new NewFrame (300, 200); } }