// BugTester.java // Tests the user-defined abstract superclass Bug and various subclasses // Example of dynamic method binding and polymorphism import java.awt.*; import java.awt.event.*; import javax.swing.*; public class BugTester extends JApplet { // GUI Container c; JPanel pGUI; BugPanel pD; JButton b; public void init( ) { c = getContentPane( ); pGUI = new JPanel( ); b = new JButton( "Bugs" ); b.addActionListener( new ActionListener( ) { public void actionPerformed( ActionEvent e ) { pD.repaint( ); } } ); pGUI.add( b ); c.add( pGUI, BorderLayout.NORTH ); pD = new BugPanel( ); c.add( pD, BorderLayout.CENTER ); } }