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.
In the following code following things are done:
public GenericApplet {
this.getContentPane().add(new GenericPanel());
}//end constructor
The above code adds the GenericPanel object to contentpage.
Example code:
You can learn from the following code listing
// 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