Back to Applets page
Click in the boxes below, select all and copy to grab the applet
HTML listing:
<HTML> <HEAD> <TITLE>Listing 5.1</TITLE> </HEAD> <BODY BGCOLOR=WHITE> <APPLET CODEBASE="classes" CODE="Applet1.class" WIDTH=400 HEIGHT=500> </APPLET> </BODY> </HTML>
Applet listing:
/* Simple applet to show how to declare variables */ import java.awt.*; import java.applet.Applet; public class Applet1 extends Applet{ String stringVarWithValue = "Hey, I'm a string!"; Font f = new Font("TimesRoman",Font.BOLD,36); public void init() { setBackground(Color.white); } public void paint(Graphics g) { g.setFont(f); g.drawString(this.stringVarWithValue, 50 , 150); } }