Sending Parameters to Applets

Java applets are never run from the command line, so you can't specify arguments the way you can with applications. Applets use a different way to receive information at the time the program is run. This configuration information is called parameters, and you can send parameters through the HTML page that runs the applet. You have to use a special HTML tag for parameters called param.

To see how the Blanks application would be rewritten as an applet, open your word processor, enter the text of Listing 4.5, then save the file as BlanksApplet.java.

Listing 4.5. The Full Text of BlanksApplet.java
 1: import java.awt.*; 2: 3: public class BlanksApplet extends javax.swing.JApplet { 4: String parameter1; 5: String parameter2; ...

Get SAMS Teach Yourself Programming with Java™ in 24 Hours, FOURTH EDITION now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.