Back to Applets page
Click in the boxes below, select all and copy to grab the applet
HTML listing:
<HTML> <HEAD> <TITLE>Listing 9.7</TITLE> </HEAD> <BODY BGCOLOR=WHITE> <APPLET CODEBASE="classes" CODE="Applet7.class" WIDTH=400 HEIGHT=150> </APPLET> </BODY> </HTML>
Applet listing:
import java.awt.*; import java.applet.*; public class Applet7 extends Applet { Panel northPanel, southPanel, centerPanel, eastPanel, westPanel; public void init() { setBackground(Color.white); northPanel = new Panel(); southPanel = new Panel(); centerPanel = new Panel(); eastPanel = new Panel(); westPanel = new Panel(); for (int i = 1; i<4; i++) { northPanel.add(new Button("North #" + i)); southPanel.add(new Button("South #" + i)); centerPanel.add(new Button("C #" + i)); eastPanel.add(new Button("E #" + i)); westPanel.add(new Button("W #" + i)); } this.setLayout(new BorderLayout(1,1)); add("North", northPanel); add("South", southPanel); add("Center", centerPanel); add("East", eastPanel); add("West", westPanel); } }