    001/* ========================================================================
    002 * JCommon : a free general purpose class library for the Java(tm) platform
    003 * ========================================================================
    004 *
    005 * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
    006 *
    007 * Project Info:  http://www.jfree.org/jcommon/index.html
    008 *
    009 * This library is free software; you can redistribute it and/or modify it
    010 * under the terms of the GNU Lesser General Public License as published by
    011 * the Free Software Foundation; either version 2.1 of the License, or
    012 * (at your option) any later version.
    013 *
    014 * This library is distributed in the hope that it will be useful, but
    015 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    016 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
    017 * License for more details.
    018 *
    019 * You should have received a copy of the GNU Lesser General Public
    020 * License along with this library; if not, write to the Free Software
    021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
    022 * USA.
    023 *
    024 * [Java is a trademark or registered trademark of Sun Microsystems, Inc.
    025 * in the United States and other countries.]
    026 *
    027 * ---------------------
    028 * ApplicationFrame.java
    029 * ---------------------
    030 * (C) Copyright 2000-2004, by Object Refinery Limited.
    031 *
    032 * Original Author:  David Gilbert (for Object Refinery Limited);
    033 * Contributor(s):   -;
    034 *
    035 * $Id: ApplicationFrame.java,v 1.5 2007/11/02 17:50:36 taqua Exp $
    036 *
    037 * Changes (from 30-May-2002)
    038 * --------------------------
    039 * 30-May-2002 : Added title (DG);
    040 * 13-Oct-2002 : Fixed errors reported by Checkstyle (DG);
    041 *
    042 */
    043
    044package org.jfree.ui;
    045
    046import java.awt.event.WindowEvent;
    047import java.awt.event.WindowListener;
    048import javax.swing.JFrame;
    049
    050/**
    051 * A base class for creating the main frame for simple applications.  The frame listens for
    052 * window closing events, and responds by shutting down the JVM.  This is OK for small demo
    053 * applications...for more serious applications, you'll want to use something more robust.
    054 *
    055 * @author David Gilbert
    056 */
    057public class ApplicationFrame extends JFrame implements WindowListener {
    058
    059    /**
    060     * Constructs a new application frame.
    061     *
    062     * @param title  the frame title.
    063     */
    064    public ApplicationFrame(final String title) {
    065        super(title);
    066        addWindowListener(this);
    067    }
    068
    069    /**
    070     * Listens for the main window closing, and shuts down the application.
    071     *
    072     * @param event  information about the window event.
    073     */
    074    public void windowClosing(final WindowEvent event) {
    075        if (event.getWindow() == this) {
    076            dispose();
    077            System.exit(0);
    078        }
    079    }
    080
    081    /**
    082     * Required for WindowListener interface, but not used by this class.
    083     *
    084     * @param event  information about the window event.
    085     */
    086    public void windowClosed(final WindowEvent event) {
    087        // ignore
    088    }
    089
    090    /**
    091     * Required for WindowListener interface, but not used by this class.
    092     *
    093     * @param event  information about the window event.
    094     */
    095    public void windowActivated(final WindowEvent event) {
    096        // ignore
    097    }
    098
    099    /**
    100     * Required for WindowListener interface, but not used by this class.
    101     *
    102     * @param event  information about the window event.
    103     */
    104    public void windowDeactivated(final WindowEvent event) {
    105        // ignore
    106    }
    107
    108    /**
    109     * Required for WindowListener interface, but not used by this class.
    110     *
    111     * @param event  information about the window event.
    112     */
    113    public void windowDeiconified(final WindowEvent event) {
    114        // ignore
    115    }
    116
    117    /**
    118     * Required for WindowListener interface, but not used by this class.
    119     *
    120     * @param event  information about the window event.
    121     */
    122    public void windowIconified(final WindowEvent event) {
    123        // ignore
    124    }
    125
    126    /**
    127     * Required for WindowListener interface, but not used by this class.
    128     *
    129     * @param event  information about the window event.
    130     */
    131    public void windowOpened(final WindowEvent event) {
    132        // ignore
    133    }
    134
    135}