Creating an Applet
See Also
Before you create an applet in the IDE, you must determine the type of project
from which you want to run the applet. You can create the applet in one of the
following two places:
- Within a Java Application project with Java WebStart enabled and with
an applet descriptor specified in the application's JNLP file.
- Within a Java Class Library project that is a library for a Web Application
project.
To create and run an applet that is called from a JNLP file:
- Choose File > New Project.
Under Categories, select Java. Under Projects, select Java Application.
Complete the wizard.
- Right-click the node of the new project in the Projects window
and select New > Other. Under Categories,
select Swing GUI Forms.
Under File Types, select JApplet Form. Click Next.
-
In the Class Name text field, type the name of your applet.
In the Package text field, enter the package to which the applet
will belong.
- Click Finish. The IDE creates the applet in the
specified package. The applet opens in the Source editor.
-
Design the applet with the GUI Builder or type code in the source view.
- Right-click the project's node, choose Properties, and select the Web Start panel.
- Select the Enable Web Start checkbox.
- Select the Applet Descriptor radio button and make sure that your applet
is selected in the Applet Class combo box.
- Close the Project Properties dialog box.
- Right click the project node in the Projects window and choose Build from the pop-up menu.
- Right-click the project node and choose Run Project.
To create an applet in a web application:
- Choose File > New Project.
Under Categories, select Java. Under Projects, select Java Class Library.
Complete the wizard.
- Right-click the node of the new project in the Projects window
and select New > Other. Under Categories,
select Swing GUI Forms.
Under File Types, select JApplet Form. Click Next.
-
In the Class Name text field, type the name of your applet.
In the Package text field, enter the package to which the applet
will belong.
- Click Finish. The IDE creates the applet in the
specified package. The applet opens in the Source editor.
-
Design the applet with the GUI Builder or type code in the source view.
- Right click the project node in the Projects window and choose Build from the pop-up menu.
- Run the applet.
- Note: When you create the applet, you can also choose from the JApplet
or Applet templates in the Java category. These templates do not work with the
IDE's GUI Builder.
- See Also
- Setting Permissions for an Applet
- Accessing an Applet from a JSP Page
Legal Notices