/** * @file ApplicFrame.java * @author R Daniel Bergeron * @version 2.0 * @see Draw3d.java *

* description ApplicFrame provides the window and frame when program is as * an application. * *

* modified by Robert S. Laramee * modification date Thursday 10 Dec 1998 * description changed Frame to JFrame (Swing) */ import java.applet.Applet; import java.awt.*; // needed for both Applet and Application import java.awt.event.*; import javax.swing.*; class ApplicFrame extends JFrame { // ++++++++ inner WindowListener class ++++++++ class ListenWindow extends WindowAdapter { public ListenWindow() { } // ------ windowClosing ------------------------------------ public void windowClosing (WindowEvent event) { dispose(); // kills the Window which generates a WindowClosed event } // ------ windowClosed ------------------------------------ public void windowClosed (WindowEvent event) { System.exit (0); } } // end ListenWindow class // ------ constructor ------------------------------------ public ApplicFrame( String frameTitle, Applet myApp ) { super (frameTitle); // Frame puts title on window ApplicFrame frame = this; /** * bob tries to center the window because it was coming up off of * the screen on "his" machine (panama.unh.edu) */ Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension dimension = toolkit.getScreenSize(); int screenHeight = dimension.height; int screenWidth = dimension.width; setLocation(screenWidth / 5, screenHeight / 5); myApp.init(); // and init it. myApp.start(); // and start it. // add Applet to center of Frame getContentPane().add (myApp, BorderLayout.CENTER ); addWindowListener(new ListenWindow()); } }