package jsetool.gui; import java.awt.*; import java.awt.event.*; /** * @author Mike Lawson * * @since November 12, 2004 * * The ApplicationFrame class is a Frame * that knows how to close itself. * * */ public class ApplicationFrame extends Frame { /** * Constructs a new application frame * */ public ApplicationFrame() { this(""); } /** * Constructs a new application frame with the given title. * @param title */ public ApplicationFrame(String title) { super(title); createUI(); } /** * Centers the frame on the display. * */ public void center() { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = getSize(); int x = (screenSize.width - frameSize.width) / 2; int y = (screenSize.height - frameSize.height) / 2; setLocation(x, y); } /** * Creates the user interface and adds the window * listener to actually close the display when the frame * is closed. */ protected void createUI() { setSize(500, 400); center(); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { dispose(); System.exit(0); } }); } }