This tutorial steps you through creating an AWT applet using the JBuilder integrated development environment (IDE). For more information on the IDE and its components, see "JBuilder environment" available from the Help menu.
The tutorial shows how to:
Panel
, Choice
, Label
, and Button
.
FirstApplet
sample is available in samples/Tutorials/FirstApplet
in your JBuilder directory.
For information on documentation conventions used in this tutorial, see "Documentation conventions." For additional suggestions on improving this tutorial, send email to jpgpubs@inprise.com.
It's important to remember when designing applets that browser support for Java is limited. As of this writing, Internet Explorer and Netscape support JDK 1.1.5. The browsers do not presently support Swing components, introduced in JDK 1.1.7, although they may in the future. If you are creating your applets with a more recent version of the JDK, you must be very careful to use components that the browsers support. For example, if you develop your applets strictly with AWT components, in most cases your applets will run. There may be changes in the AWT components (for example, JDK 1.1.x may have slightly different features than JDK 1.3) and you may have to modify your applet code accordingly. You can troubleshoot your applet in the browser by checking the Java Console error messages. The safest way to design your applet is by using AWT components and the JDK that the browser supports.
Another option is to design your applets using the current JDK and Swing components and provide your users with the Java Plug-in. This is usually only possible within a controlled environment, such as a company intranet. Browsers supported by the Java Plug-in, which provides the browser with the Java 2 SDK 1.3 Runtime Environment (JRE), can run JDK 1.3-based applets. There are several additional steps involved in developing applets that run with the Java Plug-in. Visit the Java Plug-in Home Page at http://www.javasoft.com/products/plugin/index.html for more information.
Although browsers support only JDK 1.1.5, in this tutorial we will use JDK 1.3. The applet will still run, however, because we are carefully selecting the components that we use. We are designing only with AWT components and avoiding any new JDK 1.3 features.
The "Good Evening" applet you create in this tutorial contains a drop-down list of language choices. When you select a language, such as German, the panel below the selection changes to the German translation of "Good Evening": "Guten Abend."
When you finish the tutorial, your applet will look similar to this:
For the complete applet code, see the "Applet source code" at the end of the tutorial.
For in-depth information on applets and deployment, see "Working with applets" and "Deploying Java programs" in Building Applications with JBuilder.
Tutorial: Building an applet
Before creating your applet, you need a project in which to store it. The Project wizard creates one for you:
Note: Projects in JBuilder are saved by default in the /[home]/jbproject
directory. It is recommended that only advanced users change this default path.
"Setting project properties" for information on switching or editing the JDK
"Runtime" topic in the "Release Notes" (Help|Release Notes) for information on running JDK 1.1.x and 1.2 applets in JBuilder
"How JBuilder constructs paths" and "Where are my files?" in "Creating and managing projects" in Building Applications with JBuilder
The wizard creates a project file and a project notes file, FirstApplet.jpr
and FirstApplet.html
, that appear in the project pane of the AppBrowser. Double-click the HTML file to see the project notes in the content pane.
/[home]/jbproject
directory. Although this can be modified, we recommend that new users use the default directories.