From 228fc33f661314b6723b691635085ee4ff6a69b2 Mon Sep 17 00:00:00 2001 From: Andrew John Hughes Date: Tue, 5 Sep 2006 20:47:38 +0000 Subject: 2006-09-05 Andrew John Hughes * Merge of HEAD-->generics from 2006/08/12 to 2006/09/03. --- javax/swing/plaf/metal/MetalButtonUI.java | 72 +++++++++++++++---------------- 1 file changed, 36 insertions(+), 36 deletions(-) (limited to 'javax/swing/plaf/metal/MetalButtonUI.java') diff --git a/javax/swing/plaf/metal/MetalButtonUI.java b/javax/swing/plaf/metal/MetalButtonUI.java index 8addfc66c..be9607927 100644 --- a/javax/swing/plaf/metal/MetalButtonUI.java +++ b/javax/swing/plaf/metal/MetalButtonUI.java @@ -54,7 +54,6 @@ import javax.swing.SwingConstants; import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.UIResource; -import javax.swing.plaf.basic.BasicButtonListener; import javax.swing.plaf.basic.BasicButtonUI; /** @@ -66,24 +65,46 @@ public class MetalButtonUI extends BasicButtonUI { - /** The color used to draw the focus rectangle around the text and/or icon. */ + /** + * The shared button UI. + */ + private static MetalButtonUI sharedUI; + + /** + * The color used to draw the focus rectangle around the text and/or icon. + */ protected Color focusColor; - /** The background color for the button when it is pressed. */ + /** + * The background color for the button when it is pressed. + */ protected Color selectColor; - /** The color for disabled button labels. */ + /** + * The color for disabled button labels. + */ protected Color disabledTextColor; + /** + * Returns a UI delegate for the specified component. + * + * @param c the component (should be a subclass of {@link AbstractButton}). + * + * @return A new instance of MetalButtonUI. + */ + public static ComponentUI createUI(JComponent c) + { + if (sharedUI == null) + sharedUI = new MetalButtonUI(); + return sharedUI; + } + /** * Creates a new instance. */ public MetalButtonUI() { super(); - focusColor = UIManager.getColor(getPropertyPrefix() + "focus"); - selectColor = UIManager.getColor(getPropertyPrefix() + "select"); - disabledTextColor = UIManager.getColor(getPropertyPrefix() + "disabledText"); } /** @@ -93,6 +114,7 @@ public class MetalButtonUI */ protected Color getFocusColor() { + focusColor = UIManager.getColor(getPropertyPrefix() + "focus"); return focusColor; } @@ -103,6 +125,7 @@ public class MetalButtonUI */ protected Color getSelectColor() { + selectColor = UIManager.getColor(getPropertyPrefix() + "select"); return selectColor; } @@ -113,21 +136,11 @@ public class MetalButtonUI */ protected Color getDisabledTextColor() { + disabledTextColor = UIManager.getColor(getPropertyPrefix() + + "disabledText"); return disabledTextColor; } - /** - * Returns a UI delegate for the specified component. - * - * @param c the component (should be a subclass of {@link AbstractButton}). - * - * @return A new instance of MetalButtonUI. - */ - public static ComponentUI createUI(JComponent c) - { - return new MetalButtonUI(); - } - /** * Installs the default settings for the specified button. * @@ -137,32 +150,19 @@ public class MetalButtonUI */ public void installDefaults(AbstractButton button) { + // This is overridden to be public, for whatever reason. super.installDefaults(button); - button.setRolloverEnabled(UIManager.getBoolean( - getPropertyPrefix() + "rollover")); } - + /** * Removes the defaults added by {@link #installDefaults(AbstractButton)}. */ public void uninstallDefaults(AbstractButton button) { + // This is overridden to be public, for whatever reason. super.uninstallDefaults(button); - button.setRolloverEnabled(false); } - /** - * Returns a button listener for the specified button. - * - * @param button the button. - * - * @return A button listener. - */ - protected BasicButtonListener createButtonListener(AbstractButton button) - { - return new MetalButtonListener(button); - } - /** * Paints the background of the button to indicate that it is in the * "pressed" state. @@ -175,7 +175,7 @@ public class MetalButtonUI if (b.isContentAreaFilled()) { Rectangle area = b.getVisibleRect(); - g.setColor(selectColor); + g.setColor(getSelectColor()); g.fillRect(area.x, area.y, area.width, area.height); } } -- cgit v1.2.1