JXFrame.java
资源名称:swingx.zip [点击查看]
上传用户:zhengdagz
上传日期:2014-03-06
资源大小:1956k
文件大小:3k
源码类别:
xml/soap/webservice
开发平台:
Java
- /*
- * $Id: JXFrame.java,v 1.6 2005/10/12 11:26:57 kleopatra Exp $
- *
- * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
- * Santa Clara, California 95054, U.S.A. All rights reserved.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
- package org.jdesktop.swingx;
- import java.awt.Component;
- import javax.swing.JFrame;
- import javax.swing.JRootPane;
- /**
- * A smarter JFrame specifically used for top level frames for Applications.
- * This frame uses a JXRootPane.
- */
- public class JXFrame extends JFrame {
- public JXFrame() {
- this(null, false);
- }
- public JXFrame(String title, boolean exitOnClose) {
- super(title);
- if (exitOnClose) {
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- }
- }
- public JXFrame(String title) {
- this(title, false);
- }
- /**
- * Overloaded to create a JXRootPane.
- */
- protected JRootPane createRootPane() {
- return new JXRootPane();
- }
- /**
- * Overloaded to make this public.
- */
- public void setRootPane(JRootPane root) {
- super.setRootPane(root);
- }
- /**
- * Add a component to the Frame.
- */
- public void addComponent(Component comp) {
- JXRootPane root = getRootPaneExt();
- if (root != null) {
- root.addComponent(comp);
- }
- // XXX should probably fire some sort of container event.
- }
- /**
- * Removes a component from the frame.
- */
- public void removeComponent(Component comp) {
- JXRootPane root = getRootPaneExt();
- if (root != null) {
- root.removeComponent(comp);
- }
- // XXX should probably fire some sort of container event.
- }
- /**
- * Return the extended root pane. If this frame doesn't contain
- * an extended root pane the root pane should be accessed with
- * getRootPane().
- *
- * @return the extended root pane or null.
- */
- public JXRootPane getRootPaneExt() {
- if (rootPane instanceof JXRootPane) {
- return (JXRootPane)rootPane;
- }
- return null;
- }
- }