Java Reference
In-Depth Information
Figure 1.3 The steps to create a Java applet and a web page to hold it. Loading the
web page in a browser or running it with the appletviewer program will display the
applet as shown in Figure 1.4.
1.8.3 First applet
Figure 1.3 shows the steps to create an applet. The following applet code displays
the string “Hello World!” in a window on a browser page:
public class HelloWorld extends java.applet.Applet
{
public void paint (java.awt.Graphics g)
{
g.drawString ("Hello World!", 45, 30);
}
}
Put this code into a file called HelloWorld.java . (Again, the name of the
file, including the cases of the letters, must match exactly with the class name
Search WWH ::




Custom Search