Back to Applets page
Click in the boxes below, select all and copy to grab the applet
HTML listing:
<HTML> <HEAD> <TITLE>Listing 10.1</TITLE> </HEAD> <BODY BGCOLOR=WHITE> <APPLET CODEBASE="classes" CODE="Applet1.class" WIDTH=47 HEIGHT=65> </APPLET> </BODY> </HTML>
Applet listing:
import java.awt.*; import java.applet.*; public class Applet1 extends Applet { Image thisCard; public void init() { int randomCard; setBackground(Color.black); randomCard = (int)(java.lang.Math.random() * 52)+1; thisCard = getImage(getCodeBase(),"card"+randomCard+".gif"); } public void paint(Graphics g) { g.drawImage(thisCard,2,2,this); } }