Back to Applets page
Click in the boxes below, select all and copy to grab the applet
HTML listing:
<HTML> <HEAD> <TITLE>Listing 9.2</TITLE> </HEAD> <BODY BGCOLOR=WHITE> <APPLET CODEBASE="classes" CODE="Applet2.class" WIDTH=400 HEIGHT=100> </APPLET> </BODY> </HTML>
Applet listing:
import java.awt.*; import java.applet.*; public class Applet2 extends Applet { public void init() { String spaces = " ",buttonText; setBackground(Color.white); this.setLayout(new FlowLayout(FlowLayout.LEFT)); for (int i=1; i<=10; i++) { buttonText = spaces.substring(1,i) + "Button #" + i + spaces.substring(1,i); this.add(new Button(buttonText)); } } }