Back to Applets page
Click in the boxes below, select all and copy to grab the applet
HTML listing:
<HTML> <HEAD> <TITLE>Listing 5.4</TITLE> </HEAD> <BODY BGCOLOR=WHITE> <APPLET CODEBASE="classes" CODE="Applet4.class" WIDTH=400 HEIGHT=500> </APPLET> </BODY> </HTML>
Applet listing:
/* A demonstration of some string methods */ import java.awt.*; import java.applet.Applet; public class Applet4 extends Applet{ String stringVar = "Hey, I'm a string!"; Font f = new Font("TimesRoman",Font.BOLD,20); public void init() { setBackground(Color.white); } public void paint(Graphics g) { g.setFont(f); g.drawString("The string is: "+this.stringVar, 50 , 50); g.drawString("The string is: \""+this.stringVar+"\"", 50 , 75); g.drawString("The string's length is: "+this.stringVar.length(), 50 , 100); g.drawString("Lower case: "+this.stringVar.toLowerCase(), 50 , 125); g.drawString("Upper case: "+this.stringVar.toUpperCase(), 50 , 150); } }