001/* ===========================================================
002 * JFreeChart : a free chart library for the Java(tm) platform
003 * ===========================================================
004 *
005 * (C) Copyright 2000-present, by David Gilbert and Contributors.
006 *
007 * Project Info:  http://www.jfree.org/jfreechart/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 * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. 
025 * Other names may be trademarks of their respective owners.]
026 *
027 */
028
029package org.jfree.chart.ui;
030
031import java.awt.event.WindowEvent;
032import java.awt.event.WindowListener;
033import javax.swing.JFrame;
034
035/**
036 * A base class for creating the main frame for simple applications.  The frame 
037 * listens for window closing events, and responds by shutting down the JVM.  
038 * This is OK for small demo applications...for more serious applications, 
039 * you'll want to use something more robust.
040 */
041public class ApplicationFrame extends JFrame implements WindowListener {
042
043    /**
044     * Constructs a new application frame.
045     *
046     * @param title  the frame title.
047     */
048    public ApplicationFrame(String title) {
049        super(title);
050        addWindowListener(this);
051    }
052
053    /**
054     * Listens for the main window closing, and shuts down the application.
055     *
056     * @param event  information about the window event.
057     */
058    @Override
059    public void windowClosing(WindowEvent event) {
060        if (event.getWindow() == this) {
061            dispose();
062            System.exit(0);
063        }
064    }
065
066    /**
067     * Required for WindowListener interface, but not used by this class.
068     *
069     * @param event  information about the window event.
070     */
071    @Override
072    public void windowClosed(WindowEvent event) {
073        // ignore
074    }
075
076    /**
077     * Required for WindowListener interface, but not used by this class.
078     *
079     * @param event  information about the window event.
080     */
081    @Override
082    public void windowActivated(WindowEvent event) {
083        // ignore
084    }
085
086    /**
087     * Required for WindowListener interface, but not used by this class.
088     *
089     * @param event  information about the window event.
090     */
091    @Override
092    public void windowDeactivated(WindowEvent event) {
093        // ignore
094    }
095
096    /**
097     * Required for WindowListener interface, but not used by this class.
098     *
099     * @param event  information about the window event.
100     */
101    @Override
102    public void windowDeiconified(WindowEvent event) {
103        // ignore
104    }
105
106    /**
107     * Required for WindowListener interface, but not used by this class.
108     *
109     * @param event  information about the window event.
110     */
111    @Override
112    public void windowIconified(WindowEvent event) {
113        // ignore
114    }
115
116    /**
117     * Required for WindowListener interface, but not used by this class.
118     *
119     * @param event  information about the window event.
120     */
121    @Override
122    public void windowOpened(WindowEvent event) {
123        // ignore
124    }
125
126}