Home Segments Top Top Previous Next

801: Sidetrip

If your applet happens to define init and start methods, your testing class must call those methods explicitly, as in the following example, to provide a faithful simulation of browser behavior:

import javax.swing.*;                            
public class MovieApplicationTestor extends MovieApplication { 
 public static void main (String argv []) { 
  JFrame frame = new JFrame("Applet Testor"); 
  MovieApplicationTestor applet = new MovieApplicationTestor(); 
  frame.getContentPane().add("Center", applet); 
  frame.setSize(350, 150); 
  frame.addWindowListener(new ApplicationClosingWindowListener()); 
  frame.show(); 
  applet.init(); 
  applet.start(); 
 } 
}