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.4 2005/11/16 15:58:41 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    
044    package org.jfree.ui;
045    
046    import java.awt.event.WindowEvent;
047    import java.awt.event.WindowListener;
048    
049    import javax.swing.JFrame;
050    
051    /**
052     * A base class for creating the main frame for simple applications.  The frame listens for
053     * window closing events, and responds by shutting down the JVM.  This is OK for small demo
054     * applications...for more serious applications, you'll want to use something more robust.
055     *
056     * @author David Gilbert
057     */
058    public class ApplicationFrame extends JFrame implements WindowListener {
059    
060        /**
061         * Constructs a new application frame.
062         *
063         * @param title  the frame title.
064         */
065        public ApplicationFrame(final String title) {
066            super(title);
067            addWindowListener(this);
068        }
069    
070        /**
071         * Listens for the main window closing, and shuts down the application.
072         *
073         * @param event  information about the window event.
074         */
075        public void windowClosing(final WindowEvent event) {
076            if (event.getWindow() == this) {
077                dispose();
078                System.exit(0);
079            }
080        }
081    
082        /**
083         * Required for WindowListener interface, but not used by this class.
084         *
085         * @param event  information about the window event.
086         */
087        public void windowClosed(final WindowEvent event) {
088            // ignore
089        }
090    
091        /**
092         * Required for WindowListener interface, but not used by this class.
093         *
094         * @param event  information about the window event.
095         */
096        public void windowActivated(final WindowEvent event) {
097            // ignore
098        }
099    
100        /**
101         * Required for WindowListener interface, but not used by this class.
102         *
103         * @param event  information about the window event.
104         */
105        public void windowDeactivated(final WindowEvent event) {
106            // ignore
107        }
108    
109        /**
110         * Required for WindowListener interface, but not used by this class.
111         *
112         * @param event  information about the window event.
113         */
114        public void windowDeiconified(final WindowEvent event) {
115            // ignore
116        }
117    
118        /**
119         * Required for WindowListener interface, but not used by this class.
120         *
121         * @param event  information about the window event.
122         */
123        public void windowIconified(final WindowEvent event) {
124            // ignore
125        }
126    
127        /**
128         * Required for WindowListener interface, but not used by this class.
129         *
130         * @param event  information about the window event.
131         */
132        public void windowOpened(final WindowEvent event) {
133            // ignore
134        }
135    
136    }