# Java Notes

# Example - Generic Applet

This file defines an applet. This template is a reasonable way to start an applet, where `GenericPanel` is a subclass of `JPanel` and it contains the code to build a GUI with the appropriate listeners.

This will work for many applets, but there are additional methods that might be implemented if parameters or animation are used.

    // GenericApplet.java - A template for applets.
    // Fred Swartz, 2003-Apr

    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;

    //////////////////////////////////////////////////// class GenericApplet
    class GenericApplet extends JApplet{

        //====================================================== constructor
        public GenericApplet {
            this.getContentPane().add(new GenericPanel());
        }//end constructor

    }//endclass GenericApplet

The text from the above example can be selected, copied, and pasted into an editor. The boxes will be ignored.