How to turn a Java application into a Java Applet
The application program needs to be GUI-based.
- Import the classes java.awt.Graphics and javax.swing.JApplet.
- Make the class for the program extend JApplet instead of JFrame.
- Change the constructor method of the application to a method named init, that returns a void value.
- Remove the setTitle( ), setSize( ), and setVisible( ) methods from the program.
- Get rid of the main( ) method completely. Applets don’t use a main( ) method, only applications do.
This should handle simple GUI applications — more complex applications may require taking some of your event listeners and putting them into an overloaded paint( ) method (see chapter 13 in the textbook for examples).
