Professional Documents
Culture Documents
source code
run HelloWorld.class
Put in test.html:
<html>
<title>Test the applet</title>
<body>
<h3>Test the applet</h3>
<applet code=“HelloWorld.class” height=“200”
width=“300”>
</applet>
</body></html>
Cool Applet Methods
Basic methods on Applet
init(): called once for your applet
start(): called every time you enter the page
stop(): called every time you leave the page
destroy(): called when your page is discarded
Funky methods on Applet
AudioClip getAudioClip(URL url): gets audioClip object (play
with audioClip.play())
Image getImage(URL url): starts asynchronous image loading
java.net.URL constructor takes normal string argument (used to
store URLs)
void showDocument(URL url): tells browser to load new
document
void showStatus(String msg): writes to browser status line
Applet repainting
paint(): defaults to nothing
update(): clears screen, calls paint()
repaint(): passes events to Motif/Win32 don’t override/change this
t!
Java Language Basics not
an i n
Point p;
Or this ( + String operator):
int[] values;
int total=0;
for (int i=0;i<value.length;i++) {
total += values[i];
}
Array Literals
You can use array literals like
C/C++ (no need for new keyword):
http://java.sun.com/docs/books/tutorial/uiswing/co
mponents/layeredpane.html