GUI Changes: The AWT Grows Up |
Due to security restrictions, you currently can't distribute the Swing classes in an applet. However, if the Swing classes are in your class path, you can sometimes run Swing-based applets in 1.1 browsers that are written in Java. The applets tend to crash after a little while. Obviously, we plan to fix this.Do you see three buttons just below this paragraph? If so, you're successfully running a Swing-based applet!
The rest of this page gives step-by-step instructions for running Swing-based applets and tells you about limitations of Swing-based applets.
Step by Step: Running a Swing-Based Applet
- Find a 1.1 browser that's written in Java. Make sure you have the latest version, since later versions tend to have bug fixes that make Swing work better. Two 1.1 Java browsers are the HotJava browser and the Applet Viewer (
appletviewer
), which is distributed in the JDK,
- Make sure the Swing classes are in your browser's class path.
- Start your Java browser and point it at a page such as this one that contains a Swing-based applet.
Limitations of Swing-Based Applets
Swing applets currently generate security exceptions. As long as the applet works properly, you can ignore these exceptions.You might not be able to use images in Swing applets [check why]. For example, the applet on this page is based on the application explained on the page
How to Use Buttons
. That application uses images in the buttons. I had to strip the images from the buttons to get the code running in an applet.
GUI Changes: The AWT Grows Up |