Step by Step Instructions for Creating Your First Applet in NetBeans
- Choose File / New Project. Under Categories, select
General. Under Projects, select Java Class Library. Click Next.
- Under Project Name, enter
the name of your application. Change the Project Location to any
folder on your computer.
- Click Finish. The IDE
creates the project folder.
- Right-click the project node
in the Projects window or Files window and
select New > Other. Under Categories, select Swing GUI Forms. Under
File Types, select JApplet Form. Click Next.
- Under Class Name, enter the
name of your applet. Leave Package blank for now (default package).
- Click Finish. The IDE
creates the applet in the specified package. The applet opens in the
Source editor.
- Add several components
(click component, click on design panel; OR right-click on design panel
and choose Add>).
- Repeat steps 8 & 9 as
necessary (see below for instructions for specific components).
- To build project: Right
click the project node in the Projects window and choose Build from the
contextual menu.
- To Run - Right click on
Projects.../<appletname>.java select
Run File (or SHIFT-F6)
- To post to web server as JAR
file (1 archive for all source):
- Make sure you have
just Run the project (step #10 above).
- Copy JAR file (should
be in <projdir>\dist\<projname>.jar) to web server (contains code and
images).
- Copy then edit
automatically generated HTML test file (should be in <projdir>\build\<projname>.html )(NOTE: every time you Run
step #10 NetBeans re-creates this file!)
1.
remove 'codebase="..."' property in
APPLET tag
2.
add 'archive="<projname>.jar"'
property to APPLET tag
Component-specific Instructions
to add icon images to buttons or labels
(to get automatically bundled in the JAR file)
1. Copy
GIF or JPG to \src directory.
2. Select
icon... property of component and select Classpath
radio button option
3. Click
Select File and pick image file from src directory
to populate a JComboBox
1. First
add the combo box to the panel. Then edit the 'model' property.
to add a Menu
1.
First add a MenuBar to the JApplet.
2.
Right click on the JMenuBar object in the
Inspector, and select Add Menu (to add another menu.
3.
To add items to a menu, expland the JMenuBar object in
the Inpector, right click on the JMenu,
choose Add From Palette > Menu Item
to add a nested JPanel
1.
Add the Panel to Display.
2.
Add contained components. Note that the Panel will appear very small
until you start adding things into it.