diff options
Diffstat (limited to 'libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java')
-rw-r--r-- | libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java | 155 |
1 files changed, 109 insertions, 46 deletions
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java b/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java index cc262948ded..73d3e6173d3 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicInternalFrameTitlePane.java @@ -84,6 +84,14 @@ public class BasicInternalFrameTitlePane extends JComponent public class CloseAction extends AbstractAction { /** + * Creates a new action. + */ + public CloseAction() + { + super("Close"); + } + + /** * This method is called when something closes the JInternalFrame. * * @param e The ActionEvent. @@ -92,13 +100,14 @@ public class BasicInternalFrameTitlePane extends JComponent { if (frame.isClosable()) { - try - { - frame.setClosed(true); - } - catch (PropertyVetoException pve) - { - } + try + { + frame.setClosed(true); + } + catch (PropertyVetoException pve) + { + // We do nothing if the attempt has been vetoed. + } } } } @@ -113,6 +122,14 @@ public class BasicInternalFrameTitlePane extends JComponent public class IconifyAction extends AbstractAction { /** + * Creates a new action. + */ + public IconifyAction() + { + super("Minimize"); + } + + /** * This method is called when the user wants to iconify the * JInternalFrame. * @@ -122,13 +139,14 @@ public class BasicInternalFrameTitlePane extends JComponent { if (frame.isIconifiable() && ! frame.isIcon()) { - try - { - frame.setIcon(true); - } - catch (PropertyVetoException pve) - { - } + try + { + frame.setIcon(true); + } + catch (PropertyVetoException pve) + { + // We do nothing if the attempt has been vetoed. + } } } } @@ -143,6 +161,13 @@ public class BasicInternalFrameTitlePane extends JComponent public class MaximizeAction extends AbstractAction { /** + * Creates a new action. + */ + public MaximizeAction() + { + super("Maximize"); + } + /** * This method is called when the user wants to maximize the * JInternalFrame. * @@ -152,13 +177,14 @@ public class BasicInternalFrameTitlePane extends JComponent { try { - if (frame.isMaximizable() && ! frame.isMaximum()) - frame.setMaximum(true); - else if (frame.isMaximum()) - frame.setMaximum(false); + if (frame.isMaximizable() && ! frame.isMaximum()) + frame.setMaximum(true); + else if (frame.isMaximum()) + frame.setMaximum(false); } catch (PropertyVetoException pve) { + // We do nothing if the attempt has been vetoed. } } } @@ -173,6 +199,13 @@ public class BasicInternalFrameTitlePane extends JComponent public class MoveAction extends AbstractAction { /** + * Creates a new action. + */ + public MoveAction() + { + super("Move"); + } + /** * This method is called when the user wants to drag the JInternalFrame. * * @param e The ActionEvent. @@ -194,6 +227,13 @@ public class BasicInternalFrameTitlePane extends JComponent public class RestoreAction extends AbstractAction { /** + * Creates a new action. + */ + public RestoreAction() + { + super("Restore"); + } + /** * This method is called when the user wants to restore the * JInternalFrame. * @@ -203,13 +243,14 @@ public class BasicInternalFrameTitlePane extends JComponent { if (frame.isMaximum()) { - try - { - frame.setMaximum(false); - } - catch (PropertyVetoException pve) - { - } + try + { + frame.setMaximum(false); + } + catch (PropertyVetoException pve) + { + // We do nothing if the attempt has been vetoed. + } } } } @@ -224,6 +265,13 @@ public class BasicInternalFrameTitlePane extends JComponent public class SizeAction extends AbstractAction { /** + * Creates a new action. + */ + public SizeAction() + { + super("Size"); + } + /** * This method is called when the user wants to resize the JInternalFrame. * * @param e The ActionEvent. @@ -377,24 +425,26 @@ public class BasicInternalFrameTitlePane extends JComponent int loc = width + insets.left - 1; int top = insets.top + 1; - int buttonWidth = height - 2; int buttonHeight = height - 4; if (closeButton.isVisible()) { - loc -= buttonWidth + 2; - closeButton.setBounds(loc, top, buttonWidth, buttonHeight); + int buttonWidth = closeIcon.getIconWidth(); + loc -= buttonWidth + 2; + closeButton.setBounds(loc, top, buttonWidth, buttonHeight); } if (maxButton.isVisible()) { - loc -= buttonWidth + 2; - maxButton.setBounds(loc, top, buttonWidth, buttonHeight); + int buttonWidth = maxIcon.getIconWidth(); + loc -= buttonWidth + 2; + maxButton.setBounds(loc, top, buttonWidth, buttonHeight); } if (iconButton.isVisible()) { - loc -= buttonWidth + 2; - iconButton.setBounds(loc, top, buttonWidth, buttonHeight); + int buttonWidth = iconIcon.getIconWidth(); + loc -= buttonWidth + 2; + iconButton.setBounds(loc, top, buttonWidth, buttonHeight); } if (title != null) @@ -435,6 +485,7 @@ public class BasicInternalFrameTitlePane extends JComponent */ public void removeLayoutComponent(Component c) { + // Nothing to do here. } } @@ -466,6 +517,7 @@ public class BasicInternalFrameTitlePane extends JComponent // These buttons cannot be given focus. return false; } + } /** The action command for the Close action. */ @@ -522,6 +574,9 @@ public class BasicInternalFrameTitlePane extends JComponent /** The icon displayed in the iconify button. */ protected Icon iconIcon = BasicIconFactory.createEmptyFrameIcon(); + /** The icon displayed in the close button. */ + protected Icon closeIcon; + /** The JInternalFrame that this TitlePane is used in. */ protected JInternalFrame frame; @@ -645,7 +700,7 @@ public class BasicInternalFrameTitlePane extends JComponent */ protected void installListeners() { - propertyChangeListener = new PropertyChangeHandler(); + propertyChangeListener = createPropertyChangeListener(); frame.addPropertyChangeListener(propertyChangeListener); } @@ -663,14 +718,17 @@ public class BasicInternalFrameTitlePane extends JComponent */ protected void installDefaults() { - // FIXME: move icons to defaults. UIDefaults defaults = UIManager.getLookAndFeelDefaults(); - setFont(defaults.getFont("InternalFrame.titleFont")); + title.setFont(defaults.getFont("InternalFrame.titleFont")); selectedTextColor = defaults.getColor("InternalFrame.activeTitleForeground"); selectedTitleColor = defaults.getColor("InternalFrame.activeTitleBackground"); notSelectedTextColor = defaults.getColor("InternalFrame.inactiveTitleForeground"); notSelectedTitleColor = defaults.getColor("InternalFrame.inactiveTitleBackground"); + + closeIcon = UIManager.getIcon("InternalFrame.closeIcon"); + iconIcon = UIManager.getIcon("InternalFrame.iconifyIcon"); + maxIcon = UIManager.getIcon("InternalFrame.maximizeIcon"); } /** @@ -683,6 +741,10 @@ public class BasicInternalFrameTitlePane extends JComponent selectedTitleColor = null; notSelectedTextColor = null; notSelectedTitleColor = null; + + closeIcon = null; + iconIcon = null; + maxIcon = null; } /** @@ -691,12 +753,15 @@ public class BasicInternalFrameTitlePane extends JComponent protected void createButtons() { closeButton = new PaneButton(closeAction); + closeButton.setText(null); if (!frame.isClosable()) closeButton.setVisible(false); iconButton = new PaneButton(iconifyAction); + iconButton.setText(null); if (!frame.isIconifiable()) iconButton.setVisible(false); maxButton = new PaneButton(maximizeAction); + maxButton.setText(null); if (!frame.isMaximizable()) maxButton.setVisible(false); } @@ -706,15 +771,12 @@ public class BasicInternalFrameTitlePane extends JComponent */ protected void setButtonIcons() { - Icon icon = UIManager.getIcon("InternalFrame.closeIcon"); - if (icon != null) - closeButton.setIcon(icon); - icon = UIManager.getIcon("InternalFrame.iconifyIcon"); - if (icon != null) - iconButton.setIcon(icon); - icon = UIManager.getIcon("InternalFrame.maximizeIcon"); - if (icon != null) - maxButton.setIcon(icon); + if (closeIcon != null && closeButton != null) + closeButton.setIcon(closeIcon); + if (iconIcon != null && iconButton != null) + iconButton.setIcon(iconIcon); + if (maxIcon != null && maxButton != null) + maxButton.setIcon(maxIcon); } /** @@ -816,11 +878,12 @@ public class BasicInternalFrameTitlePane extends JComponent public void paintComponent(Graphics g) { paintTitleBackground(g); - Font f = g.getFont(); - FontMetrics fm = g.getFontMetrics(f); if (frame.getTitle() != null && title != null) { Color saved = g.getColor(); + Font f = title.getFont(); + g.setFont(f); + FontMetrics fm = g.getFontMetrics(f); if (frame.isSelected()) g.setColor(selectedTextColor); else |