ptg7068951
Creating an Applet
Testing the SalutonAppletProgram
Java applets can’t be run like applications because they lack a main()
method.
Instead, to run an applet, you must add markup to a web page that con-
tains the applet. To create an example web page for SalutonApplet, create
a new web page in NetBeans by following these steps:
- Choose File, New File. The New File dialog opens.
- Choose Other from the Categories pane and HTMLFile from File
Ty p e s , t h e n c l i c k N e x t. T h e N e w H T M LFile dialog opens. - Give the file the name SalutonAppletand click Finish.
NetBeans opens the source code editor with some default HTMLmarkup.
Delete all the markup that’s been provided for you, enter Listing 17.2 into
the editor, and save the file.
LISTING 17.2 The Full Text of SalutonApplet.html
1:
2:
3:
4:
5: <bodybgcolor=”#000000”text=”#FF00FF”>
6:
This is a Java applet.
7: <applet
8: code=”SalutonApplet.class”
9: codebase=”..\..\build\classes”
10: height=”150”
11: width=”300”
12: >
13:
You need a Java-enabled browser to see this.
14:
15:
16: