How to turn a Java application into a Java Applet

The application program needs to be GUI-based.

  1. Import the classes java.awt.Graphics and javax.swing.JApplet.
  2. Make the class for the program extend JApplet instead of JFrame.
  3. Change the constructor method of the application to a method named init, that returns a void value.
  4. Remove the setTitle( ), setSize( ), and setVisible( ) methods from the program.
  5. 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).