Java Reference
In-Depth Information
Using appletviewer is reasonably straightforward, but you might not be familiar with
some of the menu options that are available as the viewer runs an applet.
The following menu options are available:
The Restart and Reload options are used to restart the execution of the applet. The
difference between these two options is that Restart does not unload the applet
before restarting it, whereas Reload does. The Reload option is equivalent to clos-
ing the applet viewer and opening it up again on the same web page.
n
The Start and Stop options are used to call the start() and stop() methods of the
applet directly.
n
The Clone option creates a second copy of the same applet running in its own win-
dow.
n
The Tag option displays the program's applet or object tag, along with the
HTML for any param tags that configure the applet.
n
Another option on the Applet pull-down menu is Info, which calls the getAppletInfo()
and getParameterInfo() methods of the applet. A programmer can implement these
methods to provide more information about the applet and the parameters that it can han-
dle.
The getAppletInfo() method will return a string that describes the applet. The
getParameterInfo() method will return an array of string arrays that specify the name,
type, and description of each parameter.
Listing B.1 contains a Java applet that demonstrates the use of these methods.
LISTING B.1
The Full Text of AppInfo.java
1: import java.awt.*;
2:
3: public class AppInfo extends javax.swing.JApplet {
4: String name, date;
5: int version;
6:
7: public String getAppletInfo() {
8: String response = “This applet demonstrates the “
9: + “use of the Applet's Info feature.”;
10: return response;
11: }
12:
13: public String[][] getParameterInfo() {
14: String[] p1 = { “Name”, “String”, “Programmer's name” };
15: String[] p2 = { “Date”, “String”, “Today's date” };
Search WWH ::




Custom Search