ALT= "Applet could not be loaded" Sorry, it is time to upgrade your browser to a Java powered one.


SOURCE CODE

// Applet which illustrates the use of buttons and windows

import java.awt.*;

public class Win extends java.applet.Applet {
    Frame myFrame = new Frame();

    public void init() {

        // Sets the layout for the applet
        setLayout(new FlowLayout(FlowLayout.CENTER, 10, 10));

		// Adds buttons and labels to the applet
		
        add( new Label("Please press the button below:"));
        Button show = new Button("Show Window");
        add(show);
        add( new Button("Close Window"));

        // Setup info for the Frame        
		
        myFrame.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10));
        myFrame.setTitle("Welcome to My First Window!");
        myFrame.add(new Label("Please Enter your name in the test box:"));
        TextField textName = new TextField(40);
        myFrame.add(textName);
     }        


     public boolean action(Event e, Object arg) {
	 
	 	// action is taken when one of the buttons is pressed
		
            if (((Button)e.target).getLabel() == "Close Window") {
                myFrame.dispose();
            }   else if (((Button)e.target).getLabel() == "Show Window") {
                myFrame.show();
                myFrame.resize(300, 175);                   
            }
            // Return required at the end of this method
            return true;
    }
}