summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java')
-rw-r--r--libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java27
1 files changed, 22 insertions, 5 deletions
diff --git a/libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java b/libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java
index 46a19bdbe9e..0b56d591442 100644
--- a/libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java
+++ b/libjava/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java
@@ -47,8 +47,8 @@ import java.awt.Rectangle;
import javax.swing.AbstractButton;
import javax.swing.JComponent;
import javax.swing.JToggleButton;
+import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
-import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.basic.BasicButtonUI;
@@ -131,10 +131,9 @@ public class MetalToggleButtonUI
public void installDefaults(AbstractButton b)
{
super.installDefaults(b);
- UIDefaults defaults = UIManager.getLookAndFeelDefaults();
- focusColor = defaults.getColor(getPropertyPrefix() + "focus");
- selectColor = defaults.getColor(getPropertyPrefix() + "select");
- disabledTextColor = defaults.getColor(getPropertyPrefix() + "disabledText");
+ focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
+ selectColor = UIManager.getColor(getPropertyPrefix() + "select");
+ disabledTextColor = UIManager.getColor(getPropertyPrefix() + "disabledText");
}
/**
@@ -200,5 +199,23 @@ public class MetalToggleButtonUI
g.drawRect(fr.x - 1, fr.y - 1, fr.width + 1, fr.height + 1);
g.setColor(saved);
}
+
+ /**
+ * If the property <code>ToggleButton.gradient</code> is set, then a gradient
+ * is painted as background, otherwise the normal superclass behaviour is
+ * called.
+ */
+ public void update(Graphics g, JComponent c)
+ {
+ if (c.isOpaque() && UIManager.get(getPropertyPrefix() + "gradient") != null)
+ {
+ MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
+ SwingConstants.VERTICAL,
+ getPropertyPrefix() + "gradient");
+ paint(g, c);
+ }
+ else
+ super.update(g, c);
+ }
}
OpenPOWER on IntegriCloud