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.*; import java.awt.*; import java.awt.event.*; public class Step1 extends Applet { // Build the display Button clear; Panel buttonPanel; MyPanel drawPanel; public void init() { super.init(); clear = new Button ( "clear" ); buttonPanel = new Panel (); drawPanel = new MyPanel (); clear.setBackground ( new Color (187, 00, 00) ); clear.setForeground ( Color.white ); buttonPanel.setBackground ( new Color (00, 102, 155) ); buttonPanel.add ( clear ); drawPanel.setBackground ( Color.white ); drawPanel.setForeground ( Color.black ); setLayout ( new BorderLayout () ); add ( "North", buttonPanel ); add ( "Center", drawPanel ); } // end init } // end Step1 class MyPanel extends Panel { } // end MyPanelRun the applet