Path: blob/master/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/ui/JInternalFrameWrapper.java
41161 views
/*1* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324package sun.jvm.hotspot.ui;2526import java.awt.*;27import java.awt.event.*;28import javax.swing.*;29import javax.swing.event.*;3031public class JInternalFrameWrapper implements FrameWrapper {32private JInternalFrame frame;33private boolean hasWindowListener;34private ActionListener closingActionListener;35private ActionListener activatedActionListener;3637public JInternalFrameWrapper(JInternalFrame frame) {38this.frame = frame;39}4041public Component getComponent() { return frame; }42public Container getContentPane() { return frame.getContentPane(); }43public void setVisible(boolean visible) { frame.setVisible(visible); }44public void setSize(int x, int y) { frame.setSize(x, y); }45public void pack() { frame.pack(); }46public void show() { frame.show(); }47public void dispose() { frame.dispose(); }48public void setBackground(Color color) { frame.setBackground(color); }49public void setResizable(boolean resizable) { frame.setResizable(resizable); }50public void setClosable(boolean closable) { frame.setClosable(closable); }5152public void setClosingActionListener(ActionListener l) {53closingActionListener = l;54maybeInstallWindowListener();55}5657public void setActivatedActionListener(ActionListener l) {58activatedActionListener = l;59maybeInstallWindowListener();60}6162public void toFront() {63frame.toFront();64try {65frame.setSelected(true);66} catch (java.beans.PropertyVetoException e) {67}68}6970//----------------------------------------------------------------------71// Internals only below this point72//7374private void maybeInstallWindowListener() {75if (!hasWindowListener) {76frame.addInternalFrameListener(new InternalFrameAdapter() {77public void internalFrameClosing(InternalFrameEvent e) {78if (closingActionListener != null) {79closingActionListener.actionPerformed(null);80}81}8283public void internalFrameActivated(InternalFrameEvent e) {84if (activatedActionListener != null) {85activatedActionListener.actionPerformed(null);86}87}88});89hasWindowListener = true;90}91}92}939495