Back to Applets page
Click in the boxes below, select all and copy to grab the applet
HTML listing:
<HTML> <HEAD> <TITLE>Listing 9.4</TITLE> </HEAD> <BODY BGCOLOR=WHITE> <APPLET CODEBASE="classes" CODE="Applet4.class" WIDTH=400 HEIGHT=100> </APPLET> </BODY> </HTML>
Applet listing:
import java.awt.*; import java.applet.*; public class Applet4 extends Applet { public void init() { String[] borders = {"North","West","Center","East","South"}; setBackground(Color.white); this.setLayout(new BorderLayout(35,5)); for (int i=0; i<5; i++) { this.add(borders[i], new Button(borders[i] + " Button")); } } }