0N/A/*
2362N/A * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.swing.plaf.basic;
0N/A
0N/Aimport sun.swing.SwingUtilities2;
0N/Aimport java.awt.*;
0N/Aimport java.awt.event.*;
0N/Aimport javax.accessibility.AccessibleContext;
0N/Aimport javax.swing.*;
0N/Aimport javax.swing.plaf.*;
0N/Aimport javax.swing.border.*;
0N/Aimport javax.swing.event.InternalFrameEvent;
0N/Aimport java.util.EventListener;
0N/Aimport java.beans.PropertyChangeListener;
0N/Aimport java.beans.PropertyChangeEvent;
0N/Aimport java.beans.VetoableChangeListener;
0N/Aimport java.beans.PropertyVetoException;
0N/A
0N/Aimport sun.swing.DefaultLookup;
0N/Aimport sun.swing.UIAction;
0N/A
0N/A/**
0N/A * The class that manages a basic title bar
0N/A * <p>
0N/A * <strong>Warning:</strong>
0N/A * Serialized objects of this class will not be compatible with
0N/A * future Swing releases. The current serialization support is
0N/A * appropriate for short term storage or RMI between applications running
0N/A * the same version of Swing. As of 1.4, support for long term storage
0N/A * of all JavaBeans<sup><font size="-2">TM</font></sup>
0N/A * has been added to the <code>java.beans</code> package.
0N/A * Please see {@link java.beans.XMLEncoder}.
0N/A *
0N/A * @author David Kloba
0N/A * @author Steve Wilson
0N/A */
0N/Apublic class BasicInternalFrameTitlePane extends JComponent
0N/A{
0N/A protected JMenuBar menuBar;
0N/A protected JButton iconButton;
0N/A protected JButton maxButton;
0N/A protected JButton closeButton;
0N/A
0N/A protected JMenu windowMenu;
0N/A protected JInternalFrame frame;
0N/A
0N/A protected Color selectedTitleColor;
0N/A protected Color selectedTextColor;
0N/A protected Color notSelectedTitleColor;
0N/A protected Color notSelectedTextColor;
0N/A
0N/A protected Icon maxIcon;
0N/A protected Icon minIcon;
0N/A protected Icon iconIcon;
0N/A protected Icon closeIcon;
0N/A
0N/A protected PropertyChangeListener propertyChangeListener;
0N/A
0N/A protected Action closeAction;
0N/A protected Action maximizeAction;
0N/A protected Action iconifyAction;
0N/A protected Action restoreAction;
0N/A protected Action moveAction;
0N/A protected Action sizeAction;
0N/A
609N/A // These constants are not used in JDK code
0N/A protected static final String CLOSE_CMD =
0N/A UIManager.getString("InternalFrameTitlePane.closeButtonText");
0N/A protected static final String ICONIFY_CMD =
0N/A UIManager.getString("InternalFrameTitlePane.minimizeButtonText");
0N/A protected static final String RESTORE_CMD =
0N/A UIManager.getString("InternalFrameTitlePane.restoreButtonText");
0N/A protected static final String MAXIMIZE_CMD =
0N/A UIManager.getString("InternalFrameTitlePane.maximizeButtonText");
0N/A protected static final String MOVE_CMD =
0N/A UIManager.getString("InternalFrameTitlePane.moveButtonText");
0N/A protected static final String SIZE_CMD =
0N/A UIManager.getString("InternalFrameTitlePane.sizeButtonText");
0N/A
0N/A private String closeButtonToolTip;
0N/A private String iconButtonToolTip;
0N/A private String restoreButtonToolTip;
0N/A private String maxButtonToolTip;
0N/A private Handler handler;
0N/A
0N/A public BasicInternalFrameTitlePane(JInternalFrame f) {
0N/A frame = f;
0N/A installTitlePane();
0N/A }
0N/A
0N/A protected void installTitlePane() {
0N/A installDefaults();
0N/A installListeners();
0N/A
0N/A createActions();
0N/A enableActions();
0N/A createActionMap();
0N/A
0N/A setLayout(createLayout());
0N/A
0N/A assembleSystemMenu();
0N/A createButtons();
0N/A addSubComponents();
0N/A
0N/A }
0N/A
0N/A protected void addSubComponents() {
0N/A add(menuBar);
0N/A add(iconButton);
0N/A add(maxButton);
0N/A add(closeButton);
0N/A }
0N/A
0N/A protected void createActions() {
0N/A maximizeAction = new MaximizeAction();
0N/A iconifyAction = new IconifyAction();
0N/A closeAction = new CloseAction();
0N/A restoreAction = new RestoreAction();
0N/A moveAction = new MoveAction();
0N/A sizeAction = new SizeAction();
0N/A }
0N/A
0N/A ActionMap createActionMap() {
0N/A ActionMap map = new ActionMapUIResource();
0N/A map.put("showSystemMenu", new ShowSystemMenuAction(true));
0N/A map.put("hideSystemMenu", new ShowSystemMenuAction(false));
0N/A return map;
0N/A }
0N/A
0N/A protected void installListeners() {
0N/A if( propertyChangeListener == null ) {
0N/A propertyChangeListener = createPropertyChangeListener();
0N/A }
0N/A frame.addPropertyChangeListener(propertyChangeListener);
0N/A }
0N/A
0N/A protected void uninstallListeners() {
0N/A frame.removePropertyChangeListener(propertyChangeListener);
0N/A handler = null;
0N/A }
0N/A
0N/A protected void installDefaults() {
0N/A maxIcon = UIManager.getIcon("InternalFrame.maximizeIcon");
0N/A minIcon = UIManager.getIcon("InternalFrame.minimizeIcon");
0N/A iconIcon = UIManager.getIcon("InternalFrame.iconifyIcon");
0N/A closeIcon = UIManager.getIcon("InternalFrame.closeIcon");
0N/A
0N/A selectedTitleColor = UIManager.getColor("InternalFrame.activeTitleBackground");
0N/A selectedTextColor = UIManager.getColor("InternalFrame.activeTitleForeground");
0N/A notSelectedTitleColor = UIManager.getColor("InternalFrame.inactiveTitleBackground");
0N/A notSelectedTextColor = UIManager.getColor("InternalFrame.inactiveTitleForeground");
0N/A setFont(UIManager.getFont("InternalFrame.titleFont"));
0N/A closeButtonToolTip =
0N/A UIManager.getString("InternalFrame.closeButtonToolTip");
0N/A iconButtonToolTip =
0N/A UIManager.getString("InternalFrame.iconButtonToolTip");
0N/A restoreButtonToolTip =
0N/A UIManager.getString("InternalFrame.restoreButtonToolTip");
0N/A maxButtonToolTip =
0N/A UIManager.getString("InternalFrame.maxButtonToolTip");
0N/A }
0N/A
0N/A
0N/A protected void uninstallDefaults() {
0N/A }
0N/A
0N/A protected void createButtons() {
0N/A iconButton = new NoFocusButton(
0N/A "InternalFrameTitlePane.iconifyButtonAccessibleName",
0N/A "InternalFrameTitlePane.iconifyButtonOpacity");
0N/A iconButton.addActionListener(iconifyAction);
0N/A if (iconButtonToolTip != null && iconButtonToolTip.length() != 0) {
0N/A iconButton.setToolTipText(iconButtonToolTip);
0N/A }
0N/A
0N/A maxButton = new NoFocusButton(
0N/A "InternalFrameTitlePane.maximizeButtonAccessibleName",
0N/A "InternalFrameTitlePane.maximizeButtonOpacity");
0N/A maxButton.addActionListener(maximizeAction);
0N/A
0N/A closeButton = new NoFocusButton(
0N/A "InternalFrameTitlePane.closeButtonAccessibleName",
0N/A "InternalFrameTitlePane.closeButtonOpacity");
0N/A closeButton.addActionListener(closeAction);
0N/A if (closeButtonToolTip != null && closeButtonToolTip.length() != 0) {
0N/A closeButton.setToolTipText(closeButtonToolTip);
0N/A }
0N/A
0N/A setButtonIcons();
0N/A }
0N/A
0N/A protected void setButtonIcons() {
0N/A if(frame.isIcon()) {
0N/A if (minIcon != null) {
0N/A iconButton.setIcon(minIcon);
0N/A }
0N/A if (restoreButtonToolTip != null &&
0N/A restoreButtonToolTip.length() != 0) {
0N/A iconButton.setToolTipText(restoreButtonToolTip);
0N/A }
0N/A if (maxIcon != null) {
0N/A maxButton.setIcon(maxIcon);
0N/A }
0N/A if (maxButtonToolTip != null && maxButtonToolTip.length() != 0) {
0N/A maxButton.setToolTipText(maxButtonToolTip);
0N/A }
0N/A } else if (frame.isMaximum()) {
0N/A if (iconIcon != null) {
0N/A iconButton.setIcon(iconIcon);
0N/A }
0N/A if (iconButtonToolTip != null && iconButtonToolTip.length() != 0) {
0N/A iconButton.setToolTipText(iconButtonToolTip);
0N/A }
0N/A if (minIcon != null) {
0N/A maxButton.setIcon(minIcon);
0N/A }
0N/A if (restoreButtonToolTip != null &&
0N/A restoreButtonToolTip.length() != 0) {
0N/A maxButton.setToolTipText(restoreButtonToolTip);
0N/A }
0N/A } else {
0N/A if (iconIcon != null) {
0N/A iconButton.setIcon(iconIcon);
0N/A }
0N/A if (iconButtonToolTip != null && iconButtonToolTip.length() != 0) {
0N/A iconButton.setToolTipText(iconButtonToolTip);
0N/A }
0N/A if (maxIcon != null) {
0N/A maxButton.setIcon(maxIcon);
0N/A }
0N/A if (maxButtonToolTip != null && maxButtonToolTip.length() != 0) {
0N/A maxButton.setToolTipText(maxButtonToolTip);
0N/A }
0N/A }
0N/A if (closeIcon != null) {
0N/A closeButton.setIcon(closeIcon);
0N/A }
0N/A }
0N/A
0N/A protected void assembleSystemMenu() {
0N/A menuBar = createSystemMenuBar();
0N/A windowMenu = createSystemMenu();
0N/A menuBar.add(windowMenu);
0N/A addSystemMenuItems(windowMenu);
0N/A enableActions();
0N/A }
0N/A
0N/A protected void addSystemMenuItems(JMenu systemMenu) {
614N/A JMenuItem mi = systemMenu.add(restoreAction);
0N/A mi.setMnemonic('R');
614N/A mi = systemMenu.add(moveAction);
0N/A mi.setMnemonic('M');
614N/A mi = systemMenu.add(sizeAction);
0N/A mi.setMnemonic('S');
614N/A mi = systemMenu.add(iconifyAction);
0N/A mi.setMnemonic('n');
614N/A mi = systemMenu.add(maximizeAction);
0N/A mi.setMnemonic('x');
0N/A systemMenu.add(new JSeparator());
614N/A mi = systemMenu.add(closeAction);
0N/A mi.setMnemonic('C');
0N/A }
0N/A
0N/A protected JMenu createSystemMenu() {
0N/A return new JMenu(" ");
0N/A }
0N/A
0N/A protected JMenuBar createSystemMenuBar() {
0N/A menuBar = new SystemMenuBar();
0N/A menuBar.setBorderPainted(false);
0N/A return menuBar;
0N/A }
0N/A
0N/A protected void showSystemMenu(){
0N/A // windowMenu.setPopupMenuVisible(true);
0N/A // windowMenu.setVisible(true);
0N/A windowMenu.doClick();
0N/A }
0N/A
0N/A public void paintComponent(Graphics g) {
0N/A paintTitleBackground(g);
0N/A
0N/A if(frame.getTitle() != null) {
0N/A boolean isSelected = frame.isSelected();
0N/A Font f = g.getFont();
0N/A g.setFont(getFont());
0N/A if(isSelected)
0N/A g.setColor(selectedTextColor);
0N/A else
0N/A g.setColor(notSelectedTextColor);
0N/A
0N/A // Center text vertically.
0N/A FontMetrics fm = SwingUtilities2.getFontMetrics(frame, g);
0N/A int baseline = (getHeight() + fm.getAscent() - fm.getLeading() -
0N/A fm.getDescent()) / 2;
0N/A
0N/A int titleX;
0N/A Rectangle r = new Rectangle(0, 0, 0, 0);
0N/A if (frame.isIconifiable()) r = iconButton.getBounds();
0N/A else if (frame.isMaximizable()) r = maxButton.getBounds();
0N/A else if (frame.isClosable()) r = closeButton.getBounds();
0N/A int titleW;
0N/A
0N/A String title = frame.getTitle();
0N/A if( BasicGraphicsUtils.isLeftToRight(frame) ) {
0N/A if (r.x == 0) r.x = frame.getWidth()-frame.getInsets().right;
0N/A titleX = menuBar.getX() + menuBar.getWidth() + 2;
0N/A titleW = r.x - titleX - 3;
0N/A title = getTitle(frame.getTitle(), fm, titleW);
0N/A } else {
0N/A titleX = menuBar.getX() - 2
0N/A - SwingUtilities2.stringWidth(frame,fm,title);
0N/A }
0N/A
0N/A SwingUtilities2.drawString(frame, g, title, titleX, baseline);
0N/A g.setFont(f);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Invoked from paintComponent.
0N/A * Paints the background of the titlepane. All text and icons will
0N/A * then be rendered on top of this background.
0N/A * @param g the graphics to use to render the background
0N/A * @since 1.4
0N/A */
0N/A protected void paintTitleBackground(Graphics g) {
0N/A boolean isSelected = frame.isSelected();
0N/A
0N/A if(isSelected)
0N/A g.setColor(selectedTitleColor);
0N/A else
0N/A g.setColor(notSelectedTitleColor);
0N/A g.fillRect(0, 0, getWidth(), getHeight());
0N/A }
0N/A
0N/A protected String getTitle(String text, FontMetrics fm, int availTextWidth) {
0N/A return SwingUtilities2.clipStringIfNecessary(
0N/A frame, fm, text, availTextWidth);
0N/A }
0N/A
0N/A /**
0N/A * Post a WINDOW_CLOSING-like event to the frame, so that it can
0N/A * be treated like a regular Frame.
0N/A */
0N/A protected void postClosingEvent(JInternalFrame frame) {
0N/A InternalFrameEvent e = new InternalFrameEvent(
0N/A frame, InternalFrameEvent.INTERNAL_FRAME_CLOSING);
0N/A // Try posting event, unless there's a SecurityManager.
0N/A if (JInternalFrame.class.getClassLoader() == null) {
0N/A try {
0N/A Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(e);
0N/A return;
0N/A } catch (SecurityException se) {
0N/A // Use dispatchEvent instead.
0N/A }
0N/A }
0N/A frame.dispatchEvent(e);
0N/A }
0N/A
0N/A
0N/A protected void enableActions() {
0N/A restoreAction.setEnabled(frame.isMaximum() || frame.isIcon());
0N/A maximizeAction.setEnabled(
0N/A (frame.isMaximizable() && !frame.isMaximum() && !frame.isIcon()) ||
0N/A (frame.isMaximizable() && frame.isIcon()));
0N/A iconifyAction.setEnabled(frame.isIconifiable() && !frame.isIcon());
0N/A closeAction.setEnabled(frame.isClosable());
0N/A sizeAction.setEnabled(false);
0N/A moveAction.setEnabled(false);
0N/A }
0N/A
0N/A private Handler getHandler() {
0N/A if (handler == null) {
0N/A handler = new Handler();
0N/A }
0N/A return handler;
0N/A }
0N/A
0N/A protected PropertyChangeListener createPropertyChangeListener() {
0N/A return getHandler();
0N/A }
0N/A
0N/A protected LayoutManager createLayout() {
0N/A return getHandler();
0N/A }
0N/A
0N/A
0N/A private class Handler implements LayoutManager, PropertyChangeListener {
0N/A //
0N/A // PropertyChangeListener
0N/A //
0N/A public void propertyChange(PropertyChangeEvent evt) {
614N/A String prop = evt.getPropertyName();
0N/A
0N/A if (prop == JInternalFrame.IS_SELECTED_PROPERTY) {
0N/A repaint();
0N/A return;
0N/A }
0N/A
0N/A if (prop == JInternalFrame.IS_ICON_PROPERTY ||
0N/A prop == JInternalFrame.IS_MAXIMUM_PROPERTY) {
0N/A setButtonIcons();
0N/A enableActions();
0N/A return;
0N/A }
0N/A
0N/A if ("closable" == prop) {
614N/A if (evt.getNewValue() == Boolean.TRUE) {
0N/A add(closeButton);
0N/A } else {
0N/A remove(closeButton);
0N/A }
0N/A } else if ("maximizable" == prop) {
614N/A if (evt.getNewValue() == Boolean.TRUE) {
0N/A add(maxButton);
0N/A } else {
0N/A remove(maxButton);
0N/A }
0N/A } else if ("iconable" == prop) {
614N/A if (evt.getNewValue() == Boolean.TRUE) {
0N/A add(iconButton);
0N/A } else {
0N/A remove(iconButton);
0N/A }
0N/A }
0N/A enableActions();
0N/A
0N/A revalidate();
0N/A repaint();
0N/A }
0N/A
0N/A
0N/A //
0N/A // LayoutManager
0N/A //
0N/A public void addLayoutComponent(String name, Component c) {}
0N/A public void removeLayoutComponent(Component c) {}
0N/A public Dimension preferredLayoutSize(Container c) {
0N/A return minimumLayoutSize(c);
0N/A }
0N/A
0N/A public Dimension minimumLayoutSize(Container c) {
0N/A // Calculate width.
0N/A int width = 22;
0N/A
0N/A if (frame.isClosable()) {
0N/A width += 19;
0N/A }
0N/A if (frame.isMaximizable()) {
0N/A width += 19;
0N/A }
0N/A if (frame.isIconifiable()) {
0N/A width += 19;
0N/A }
0N/A
0N/A FontMetrics fm = frame.getFontMetrics(getFont());
0N/A String frameTitle = frame.getTitle();
0N/A int title_w = frameTitle != null ? SwingUtilities2.stringWidth(
0N/A frame, fm, frameTitle) : 0;
0N/A int title_length = frameTitle != null ? frameTitle.length() : 0;
0N/A
0N/A // Leave room for three characters in the title.
0N/A if (title_length > 3) {
0N/A int subtitle_w = SwingUtilities2.stringWidth(
0N/A frame, fm, frameTitle.substring(0, 3) + "...");
0N/A width += (title_w < subtitle_w) ? title_w : subtitle_w;
0N/A } else {
0N/A width += title_w;
0N/A }
0N/A
0N/A // Calculate height.
0N/A Icon icon = frame.getFrameIcon();
0N/A int fontHeight = fm.getHeight();
0N/A fontHeight += 2;
0N/A int iconHeight = 0;
0N/A if (icon != null) {
0N/A // SystemMenuBar forces the icon to be 16x16 or less.
0N/A iconHeight = Math.min(icon.getIconHeight(), 16);
0N/A }
0N/A iconHeight += 2;
0N/A
0N/A int height = Math.max( fontHeight, iconHeight );
0N/A
0N/A Dimension dim = new Dimension(width, height);
0N/A
0N/A // Take into account the border insets if any.
0N/A if (getBorder() != null) {
0N/A Insets insets = getBorder().getBorderInsets(c);
0N/A dim.height += insets.top + insets.bottom;
0N/A dim.width += insets.left + insets.right;
0N/A }
0N/A return dim;
0N/A }
0N/A
0N/A public void layoutContainer(Container c) {
0N/A boolean leftToRight = BasicGraphicsUtils.isLeftToRight(frame);
0N/A
0N/A int w = getWidth();
0N/A int h = getHeight();
0N/A int x;
0N/A
0N/A int buttonHeight = closeButton.getIcon().getIconHeight();
0N/A
0N/A Icon icon = frame.getFrameIcon();
0N/A int iconHeight = 0;
0N/A if (icon != null) {
0N/A iconHeight = icon.getIconHeight();
0N/A }
0N/A x = (leftToRight) ? 2 : w - 16 - 2;
0N/A menuBar.setBounds(x, (h - iconHeight) / 2, 16, 16);
0N/A
0N/A x = (leftToRight) ? w - 16 - 2 : 2;
0N/A
0N/A if (frame.isClosable()) {
0N/A closeButton.setBounds(x, (h - buttonHeight) / 2, 16, 14);
0N/A x += (leftToRight) ? -(16 + 2) : 16 + 2;
0N/A }
0N/A
0N/A if (frame.isMaximizable()) {
0N/A maxButton.setBounds(x, (h - buttonHeight) / 2, 16, 14);
0N/A x += (leftToRight) ? -(16 + 2) : 16 + 2;
0N/A }
0N/A
0N/A if (frame.isIconifiable()) {
0N/A iconButton.setBounds(x, (h - buttonHeight) / 2, 16, 14);
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * This class should be treated as a &quot;protected&quot; inner class.
0N/A * Instantiate it only within subclasses of <Foo>.
0N/A */
0N/A public class PropertyChangeHandler implements PropertyChangeListener {
0N/A // NOTE: This class exists only for backward compatability. All
0N/A // its functionality has been moved into Handler. If you need to add
0N/A // new functionality add it to the Handler, but make sure this
0N/A // class calls into the Handler.
0N/A public void propertyChange(PropertyChangeEvent evt) {
0N/A getHandler().propertyChange(evt);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * This class should be treated as a &quot;protected&quot; inner class.
0N/A * Instantiate it only within subclasses of <Foo>.
0N/A */
0N/A public class TitlePaneLayout implements LayoutManager {
0N/A // NOTE: This class exists only for backward compatability. All
0N/A // its functionality has been moved into Handler. If you need to add
0N/A // new functionality add it to the Handler, but make sure this
0N/A // class calls into the Handler.
0N/A public void addLayoutComponent(String name, Component c) {
0N/A getHandler().addLayoutComponent(name, c);
0N/A }
0N/A
0N/A public void removeLayoutComponent(Component c) {
0N/A getHandler().removeLayoutComponent(c);
0N/A }
0N/A
0N/A public Dimension preferredLayoutSize(Container c) {
0N/A return getHandler().preferredLayoutSize(c);
0N/A }
0N/A
0N/A public Dimension minimumLayoutSize(Container c) {
0N/A return getHandler().minimumLayoutSize(c);
0N/A }
0N/A
0N/A public void layoutContainer(Container c) {
0N/A getHandler().layoutContainer(c);
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * This class should be treated as a &quot;protected&quot; inner class.
0N/A * Instantiate it only within subclasses of <Foo>.
0N/A */
0N/A public class CloseAction extends AbstractAction {
0N/A public CloseAction() {
609N/A super(UIManager.getString(
609N/A "InternalFrameTitlePane.closeButtonText"));
0N/A }
0N/A
0N/A public void actionPerformed(ActionEvent e) {
0N/A if(frame.isClosable()) {
0N/A frame.doDefaultCloseAction();
0N/A }
0N/A }
0N/A } // end CloseAction
0N/A
0N/A /**
0N/A * This class should be treated as a &quot;protected&quot; inner class.
0N/A * Instantiate it only within subclasses of <Foo>.
0N/A */
0N/A public class MaximizeAction extends AbstractAction {
0N/A public MaximizeAction() {
609N/A super(UIManager.getString(
609N/A "InternalFrameTitlePane.maximizeButtonText"));
0N/A }
0N/A
0N/A public void actionPerformed(ActionEvent evt) {
0N/A if (frame.isMaximizable()) {
0N/A if (frame.isMaximum() && frame.isIcon()) {
0N/A try {
0N/A frame.setIcon(false);
0N/A } catch (PropertyVetoException e) { }
0N/A } else if (!frame.isMaximum()) {
0N/A try {
0N/A frame.setMaximum(true);
0N/A } catch (PropertyVetoException e) { }
0N/A } else {
0N/A try {
0N/A frame.setMaximum(false);
0N/A } catch (PropertyVetoException e) { }
0N/A }
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * This class should be treated as a &quot;protected&quot; inner class.
0N/A * Instantiate it only within subclasses of <Foo>.
0N/A */
0N/A public class IconifyAction extends AbstractAction {
0N/A public IconifyAction() {
609N/A super(UIManager.getString(
609N/A "InternalFrameTitlePane.minimizeButtonText"));
0N/A }
0N/A
0N/A public void actionPerformed(ActionEvent e) {
0N/A if(frame.isIconifiable()) {
0N/A if(!frame.isIcon()) {
0N/A try { frame.setIcon(true); } catch (PropertyVetoException e1) { }
0N/A } else{
0N/A try { frame.setIcon(false); } catch (PropertyVetoException e1) { }
0N/A }
0N/A }
0N/A }
0N/A } // end IconifyAction
0N/A
0N/A /**
0N/A * This class should be treated as a &quot;protected&quot; inner class.
0N/A * Instantiate it only within subclasses of <Foo>.
0N/A */
0N/A public class RestoreAction extends AbstractAction {
0N/A public RestoreAction() {
609N/A super(UIManager.getString(
609N/A "InternalFrameTitlePane.restoreButtonText"));
0N/A }
0N/A
0N/A public void actionPerformed(ActionEvent evt) {
0N/A if (frame.isMaximizable() && frame.isMaximum() && frame.isIcon()) {
0N/A try {
0N/A frame.setIcon(false);
0N/A } catch (PropertyVetoException e) { }
0N/A } else if (frame.isMaximizable() && frame.isMaximum()) {
0N/A try {
0N/A frame.setMaximum(false);
0N/A } catch (PropertyVetoException e) { }
0N/A } else if (frame.isIconifiable() && frame.isIcon()) {
0N/A try {
0N/A frame.setIcon(false);
0N/A } catch (PropertyVetoException e) { }
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * This class should be treated as a &quot;protected&quot; inner class.
0N/A * Instantiate it only within subclasses of <Foo>.
0N/A */
0N/A public class MoveAction extends AbstractAction {
0N/A public MoveAction() {
609N/A super(UIManager.getString(
609N/A "InternalFrameTitlePane.moveButtonText"));
0N/A }
0N/A
0N/A public void actionPerformed(ActionEvent e) {
0N/A // This action is currently undefined
0N/A }
0N/A } // end MoveAction
0N/A
0N/A /*
0N/A * Handles showing and hiding the system menu.
0N/A */
0N/A private class ShowSystemMenuAction extends AbstractAction {
0N/A private boolean show; // whether to show the menu
0N/A
0N/A public ShowSystemMenuAction(boolean show) {
0N/A this.show = show;
0N/A }
0N/A
0N/A public void actionPerformed(ActionEvent e) {
0N/A if (show) {
0N/A windowMenu.doClick();
0N/A } else {
0N/A windowMenu.setVisible(false);
0N/A }
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * This class should be treated as a &quot;protected&quot; inner class.
0N/A * Instantiate it only within subclasses of <Foo>.
0N/A */
0N/A public class SizeAction extends AbstractAction {
0N/A public SizeAction() {
609N/A super(UIManager.getString(
609N/A "InternalFrameTitlePane.sizeButtonText"));
0N/A }
0N/A
0N/A public void actionPerformed(ActionEvent e) {
0N/A // This action is currently undefined
0N/A }
0N/A } // end SizeAction
0N/A
0N/A
0N/A /**
0N/A * This class should be treated as a &quot;protected&quot; inner class.
0N/A * Instantiate it only within subclasses of <Foo>.
0N/A */
0N/A public class SystemMenuBar extends JMenuBar {
0N/A public boolean isFocusTraversable() { return false; }
0N/A public void requestFocus() {}
0N/A public void paint(Graphics g) {
0N/A Icon icon = frame.getFrameIcon();
0N/A if (icon == null) {
0N/A icon = (Icon)DefaultLookup.get(frame, frame.getUI(),
0N/A "InternalFrame.icon");
0N/A }
0N/A if (icon != null) {
0N/A // Resize to 16x16 if necessary.
0N/A if (icon instanceof ImageIcon && (icon.getIconWidth() > 16 || icon.getIconHeight() > 16)) {
0N/A Image img = ((ImageIcon)icon).getImage();
0N/A ((ImageIcon)icon).setImage(img.getScaledInstance(16, 16, Image.SCALE_SMOOTH));
0N/A }
0N/A icon.paintIcon(this, g, 0, 0);
0N/A }
0N/A }
0N/A
0N/A public boolean isOpaque() {
0N/A return true;
0N/A }
0N/A } // end SystemMenuBar
0N/A
0N/A
0N/A private class NoFocusButton extends JButton {
0N/A private String uiKey;
0N/A public NoFocusButton(String uiKey, String opacityKey) {
0N/A setFocusPainted(false);
0N/A setMargin(new Insets(0,0,0,0));
0N/A this.uiKey = uiKey;
0N/A
0N/A Object opacity = UIManager.get(opacityKey);
0N/A if (opacity instanceof Boolean) {
0N/A setOpaque(((Boolean)opacity).booleanValue());
0N/A }
0N/A }
0N/A public boolean isFocusTraversable() { return false; }
614N/A public void requestFocus() {}
0N/A public AccessibleContext getAccessibleContext() {
0N/A AccessibleContext ac = super.getAccessibleContext();
0N/A if (uiKey != null) {
0N/A ac.setAccessibleName(UIManager.getString(uiKey));
0N/A uiKey = null;
0N/A }
0N/A return ac;
0N/A }
614N/A } // end NoFocusButton
0N/A
0N/A} // End Title Pane Class