Step 1

In this step we build the display. It consists of a button, a panel in which to nest the button, and a panel in which we will draw and enter text. The enclosing panel for the button is useful for controlling the appearance of the button when using the BorderLayout manager.

Example Applet

import java.applet.Applet;
import java.awt.*;

public class step1 extends Applet{

// builds interface:  button, buttonPanel, and drawPanel

Button button = new Button ("Clear");
Panel buttonPanel = new Panel ( );
MyPanel drawPanel = new MyPanel ();

  public void init ( ){

    drawPanel.setBackground (Color.white);
    button.setBackground (Color.green);
    button.setFont ( new Font ("Helvetica", Font.BOLD, 18) );

    buttonPanel.add (button);

    setLayout (new BorderLayout ( ) );
    add ("North", buttonPanel);
    add ("Center", drawPanel);

  } // end init

}// end step1

class MyPanel extends Panel {

} // end MyPanel

Run the applet