Testing applets

An applet is a bean that is designed to be run inside a Web browser and that inherits from java.applet.Applet or javax.swing.JApplet .

The Eclipse-based launcher has its own applet stub that is used to run the applet. This stub automatically starts the applet after it has been instantiated by calling its start() method. Unlike the JRE applet launcher, which the Java bean launcher does not use, the stub does not check authority profiles to see whether the applet can perform tasks such as input/output or opening sockets. This means you can quickly test your applet's run-time appearance and behavior without worrying about security certificates.

To test an applet in the Java bean launcher:

  1. Proceed as you would for testing any other visual bean.
  2. On the Java Bean page of the Launch Configurations window, select the same options that you would set for testing other visual beans, for example to explicitly size the bean.
  3. On the Applet Parameters page, specify any parameters that you want to pass to the applet. Click the New button to add new parameters. These parameters will be made available to the applet under test by means of a call to the getParameter(String); method.

When you have finished testing your applet and are ready to deploy it in a browser, you can use the simple HTML <applet> tag as long as the class does not require any JDK 1.2 or higher features, such as any of the Swing classes. If your applet uses any JDK 1.2 or higher features, then the HTML syntax to embed it into a page is more complex. This is required in order to deal with differences between browsers, and to ensure that the applet uses the correct Java plug-in. For more information about applets and Java plug-ins, refer to http://www.java.sun.com.

Related concepts
Visual Editor for Java

Related tasks
Composing classes visually
Testing a Java bean

Related information
http://www.java.sun.com.

(C) Copyright IBM Corporation 2000, 2003. All Rights Reserved.