JXFrame.java
上传用户:zhengdagz
上传日期:2014-03-06
资源大小:1956k
文件大小:3k
源码类别:

xml/soap/webservice

开发平台:

Java

  1. /*
  2.  * $Id: JXFrame.java,v 1.6 2005/10/12 11:26:57 kleopatra Exp $
  3.  *
  4.  * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
  5.  * Santa Clara, California 95054, U.S.A. All rights reserved.
  6.  *
  7.  * This library is free software; you can redistribute it and/or
  8.  * modify it under the terms of the GNU Lesser General Public
  9.  * License as published by the Free Software Foundation; either
  10.  * version 2.1 of the License, or (at your option) any later version.
  11.  * 
  12.  * This library is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15.  * Lesser General Public License for more details.
  16.  * 
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this library; if not, write to the Free Software
  19.  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  20.  */
  21. package org.jdesktop.swingx;
  22. import java.awt.Component;
  23. import javax.swing.JFrame;
  24. import javax.swing.JRootPane;
  25. /**
  26.  * A smarter JFrame specifically used for top level frames for Applications.
  27.  * This frame uses a JXRootPane.
  28.  */
  29. public class JXFrame extends JFrame {
  30.     public JXFrame() {
  31.         this(null, false);
  32.     }
  33.     
  34.     public JXFrame(String title, boolean exitOnClose) {
  35.         super(title);
  36.         if (exitOnClose) {
  37.             setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  38.         }
  39.     }
  40.     public JXFrame(String title) {
  41.         this(title, false);
  42.     }
  43.     /**
  44.      * Overloaded to create a JXRootPane.
  45.      */
  46.     protected JRootPane createRootPane() {
  47.         return new JXRootPane();
  48.     }
  49.     /**
  50.      * Overloaded to make this public.
  51.      */
  52.     public void setRootPane(JRootPane root) {
  53.         super.setRootPane(root);
  54.     }
  55.     /**
  56.      * Add a component to the Frame.
  57.      */
  58.     public void addComponent(Component comp) {
  59.         JXRootPane root = getRootPaneExt();
  60.         if (root != null) {
  61.             root.addComponent(comp);
  62.         }
  63.         // XXX should probably fire some sort of container event.
  64.     }
  65.     /**
  66.      * Removes a component from the frame.
  67.      */
  68.     public void removeComponent(Component comp) {
  69.         JXRootPane root = getRootPaneExt();
  70.         if (root != null) {
  71.             root.removeComponent(comp);
  72.         }
  73.         // XXX should probably fire some sort of container event.
  74.     }
  75.     /**
  76.      * Return the extended root pane. If this frame doesn't contain
  77.      * an extended root pane the root pane should be accessed with
  78.      * getRootPane().
  79.      *
  80.      * @return the extended root pane or null.
  81.      */
  82.     public JXRootPane getRootPaneExt() {
  83.         if (rootPane instanceof JXRootPane) {
  84.             return (JXRootPane)rootPane;
  85.         }
  86.         return null;
  87.     }
  88. }