Running Applets in a Standalone Application

You can run almost any applet as an application but some are easier than others. If your applet does not use the getDocumentBase, getCodeBase, or any of the AppletContext methods, you might be able to get away with creating a frame and launching the applet in the frame. In these cases, the applet is little more than a typical AWT container (remember, the Applet class is a subclass of java.awt.Panel).

Applets are first initialized by the init method, and then started by the start method. Applications, on the other hand, are initialized and started with a static method called main. Fortunately, these methods can peacefully coexist in the same class.

By adding a main method that automatically creates a ...

Get Special Edition Using Java™ 2 Enterprise Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.