// File: TestAwt18.java (Module 9) // // Author: Rahul Simha // Created: October 21, 1998 // // A simple quit button - created outside the frame. 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); } } // End of class "NewFrame" public class TestAwt18 { public static void main (String[] argv) { NewFrame nf = new NewFrame (300, 200); // 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 the frame. nf.setLayout (new BorderLayout()); // Add the button to the frame. nf.add (b); // Call validate to reset: nf.validate(); } }