Source for org.jfree.ui.ApplicationFrame

   1: /* ========================================================================
   2:  * JCommon : a free general purpose class library for the Java(tm) platform
   3:  * ========================================================================
   4:  *
   5:  * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
   6:  * 
   7:  * Project Info:  http://www.jfree.org/jcommon/index.html
   8:  *
   9:  * This library is free software; you can redistribute it and/or modify it 
  10:  * under the terms of the GNU Lesser General Public License as published by 
  11:  * the Free Software Foundation; either version 2.1 of the License, or 
  12:  * (at your option) any later version.
  13:  *
  14:  * This library is distributed in the hope that it will be useful, but 
  15:  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
  16:  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
  17:  * License for more details.
  18:  *
  19:  * You should have received a copy of the GNU Lesser General Public
  20:  * License along with this library; if not, write to the Free Software
  21:  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
  22:  * USA.  
  23:  *
  24:  * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
  25:  * in the United States and other countries.]
  26:  * 
  27:  * ---------------------
  28:  * ApplicationFrame.java
  29:  * ---------------------
  30:  * (C) Copyright 2000-2004, by Object Refinery Limited.
  31:  *
  32:  * Original Author:  David Gilbert (for Object Refinery Limited);
  33:  * Contributor(s):   -;
  34:  *
  35:  * $Id: ApplicationFrame.java,v 1.5 2007/11/02 17:50:36 taqua Exp $
  36:  *
  37:  * Changes (from 30-May-2002)
  38:  * --------------------------
  39:  * 30-May-2002 : Added title (DG);
  40:  * 13-Oct-2002 : Fixed errors reported by Checkstyle (DG);
  41:  *
  42:  */
  43: 
  44: package org.jfree.ui;
  45: 
  46: import java.awt.event.WindowEvent;
  47: import java.awt.event.WindowListener;
  48: import javax.swing.JFrame;
  49: 
  50: /**
  51:  * A base class for creating the main frame for simple applications.  The frame listens for
  52:  * window closing events, and responds by shutting down the JVM.  This is OK for small demo
  53:  * applications...for more serious applications, you'll want to use something more robust.
  54:  *
  55:  * @author David Gilbert
  56:  */
  57: public class ApplicationFrame extends JFrame implements WindowListener {
  58: 
  59:     /**
  60:      * Constructs a new application frame.
  61:      *
  62:      * @param title  the frame title.
  63:      */
  64:     public ApplicationFrame(final String title) {
  65:         super(title);
  66:         addWindowListener(this);
  67:     }
  68: 
  69:     /**
  70:      * Listens for the main window closing, and shuts down the application.
  71:      *
  72:      * @param event  information about the window event.
  73:      */
  74:     public void windowClosing(final WindowEvent event) {
  75:         if (event.getWindow() == this) {
  76:             dispose();
  77:             System.exit(0);
  78:         }
  79:     }
  80: 
  81:     /**
  82:      * Required for WindowListener interface, but not used by this class.
  83:      *
  84:      * @param event  information about the window event.
  85:      */
  86:     public void windowClosed(final WindowEvent event) {
  87:         // ignore
  88:     }
  89: 
  90:     /**
  91:      * Required for WindowListener interface, but not used by this class.
  92:      *
  93:      * @param event  information about the window event.
  94:      */
  95:     public void windowActivated(final WindowEvent event) {
  96:         // ignore
  97:     }
  98: 
  99:     /**
 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: }