Applet wizard
The Applet wizard creates an applet consisting of two files and adds them to the existing project.
The Applet wizard creates the following two files:
- An HTML file containing an
APPLET
tag referencing your applet class. This file is generated if the Generate HTML Page option is set on Step 3 of the wizard. This is the file you should select to run or debug your applet.
- A Java class that extends
Applet
or JApplet
. This is the main UI container to which you'll add UI components using the UI designer.
See also:
"Working with applets" in Building Applications with JBuilder
"Running Java programs" in Building Applications with JBuilder
"Tutorial: Building an applet" in the Quick Start
To open the Applet wizard, choose File|New, then double-click the Applet icon. If a project isn't open, JBuilder runs the Project wizard first before running the Applet wizard.
The Applet wizard consists of three steps:
Step 1 of 3
Applet class details
The wizard displays default names for the package and applet class file.
Package
Displays the package name derived from the project file. To assign a different package name to the applet file, click in the Package field and type a new name or select an existing package name from the drop-down list.
For more information on packages, see the "Packages" topic in the "Creating and managing projects" of Building Applications with JBuilder.
Class
Displays the default name assigned to the applet class. To rename it, click in the Class field and type a new name.
Base Class To Inherit From
Displays a drop-down list box to select the class from which you want to inherit: JApplet
or Applet
.
Generate Header Comments
Uses information from the project file as header comments at the top of the applet class file. This is the information entered in the Project wizard when creating the project file.
//Title: Your Product Name
//Version:
//Copyright: Copyright (c) 1997
//Author: Your Name
//Company: Your Company
//Description: Your description
Can Run Standalone
Creates a main() method in the applet file so it can be run alone for testing without being called from an HTML page.
Generate Standard Methods
Creates the standard applet methods: start(), stop(), destroy(), getAppletInfo(), and getParameterInfo().
Step 2 of 3
Applet parameters
The grid on this page is used to enter the information that defines the parameters for your applet. This information generates PARAM
tags within the APPLET
tag of the new HTML file, and parameter-handling code in the new applet java file.
Fill in one row of the grid for each parameter you wish to have.
- To select a cell, click it or use the keyboard navigation arrows to move to it.
- To enter a value in a cell, type in a value, or select one if a drop-down list exists.
- To add a new parameter, click the Add Parameter button.
- To remove a parameter, click in any cell of the parameter row, then click the Remove Parameter button.
Name
A name for the parameter. This is used as the NAME
attribute in the PARAM
tag in the HTML file and as the name parameter of the corresponding getParameter() call in the Java source.
Type
The type of variable that is inserted in the Java source code of your applet for holding the value of the parameter coming in from the HTML page.
Desc
A brief description of the parameter. This is used to describe the parameter when external tools query the applet for what parameters it supports. An example of such a tool is the Applet|Info browser in appletviewer.
Variable
The name of the variable that is inserted into the Java source code of your applet for holding the value of the parameter coming in from the HTML page.
Default
The default value for the parameter. This is the value that the Java source code in this applet uses if a future HTML file that uses this applet doesn't have a PARAM
tag for this parameter. For an HTML file to provide this parameter, the NAME
attribute in the PARAM
tag must exactly match what you've entered in the Name column in this row of the grid. Note that this matching is case sensitive.
Step 3 of 3
HTML details
This page of the wizard controls the generation of the HTML page that is inserted in your project for testing this applet. It controls all aspects of the HTML file and its APPLET
tag, except for the parameters, which are controlled in Step 2 of the wizard.
Generate HTML Page
Determines if a new HTML page is added to your project for this applet. If this check box is off, no HTML page is generated and all the other fields on this page are disabled. If this check box is on, the other fields on this page control the TITLE
tag and the attributes of the APPLET
tag that are generated in the HTML page.
Place In Output Directory
This places the HTML applet file in the output directory with the classes. The project's output path is set in the Output Path field on the Paths page of the Project Properties dialog box. This makes testing the applet with an external browser easier as the class files and the HTML file are in the correct location.
If this option is unchecked the HTML file is saved to the source path with the other source files.
Title
The title of your HTML page which displays in the title bar of the web browser. This text is placed between the TITLE
tags in the header of the HTML page.
Name
The name of the applet, as displayed in browser messages about the applet. Note that this is not the CODE
attribute of the APPLET
tag. The CODE
tag is automatically generated from the applet class name entered on Step 1 of this wizard.
Codebase
The relative path or absolute URL to the applet .class
file location. Use this field if the applet .class
file is located in a different directory than the HMTL file on the web server. You can think of this as a single node class path for the deployed applet .class
file. A value of "." means that the .class
file and the HTML file are in the same directory.
Width
The number of pixels you want the HTML page to provide for the width of the applet. This value is assigned both to the WIDTH
attribute in the APPLET
tag on the HTML page, and to the width property of the applet's XYLayout in the Java source.
Height
The number of pixels you want the HTML page to provide for the height of the applet. This value is assigned both to the HEIGHT
attribute in the APPLET
tag on the HTML page, and to the height property of the applet's XYLayout in the Java source.
HSpace
The horizontal space to the left and right of the applet. Enter the number of pixels you want for this value. For example, if you enter a value of 20 pixels, a space 20 pixels wide is inserted on each side of the applet, between it and any surrounding text. This value is assigned to the HSPACE
attribute of the APPLET tag on the HTML page.
VSpace
The vertical space above and below the applet. Enter the number of pixels you want for this value. For example, if you enter a value of 20 pixels, a space 20 pixels high is inserted both above and below the applet, between it and any surrounding text. This value is assigned to the VSPACE
attribute of the APPLET
tag on the HTML page.
Align
Controls how the applet is aligned on the HTML page. There are five attributes on the drop-down list:
MIDDLE
aligns the middle of the applet with the middle of the text.
TOP
aligns the top of the applet with the top of the text.
BOTTOM
aligns the bottom of the applet with the bottom of the text.
LEFT
aligns the applet on the left margin of the HTML page but not inline with the text.
RIGHT
aligns the applet on the right margin of the HTML page but not inline with the text.
This value is assigned to the ALIGN
attribute in the APPLET
tag of the HTML page. You can use these additional ALIGN
values by modifying the APPLET
tag in the HTML page after it is generated by this wizard: TEXTTOP
, ABSMIDDLE
, BASELINE
, and ABSBOTTOM
.