I committed this patch to add some missing methods to MetalRadioButtonUI:
2005-09-06 David Gilbert <[EMAIL PROTECTED]> * javax/swing/plaf/metal/MetalLookAndFeel.java (initComponentDefaults): added some RadioButton defaults, * javax/swing/plaf/metal/MetalRadioButtonUI.java (instance): removed, (focusColor): added, (selectColor): added, (disabledTextColor): added, (createUI): return a new instance for every component, (installDefaults): implemented, (uninstallDefaults): implemented, (getSelectColor): implemented, (getDisabledTextColor): implemented, (getFocusColor): implemented, (paint): added FIXME note, (paintFocus): implemented. Regards, Dave Gilbert
Index: javax/swing/plaf/metal/MetalLookAndFeel.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalLookAndFeel.java,v retrieving revision 1.47 diff -u -r1.47 MetalLookAndFeel.java --- javax/swing/plaf/metal/MetalLookAndFeel.java 6 Sep 2005 19:57:34 -0000 1.47 +++ javax/swing/plaf/metal/MetalLookAndFeel.java 6 Sep 2005 20:57:59 -0000 @@ -815,6 +815,8 @@ "MenuItem.selectionBackground", getMenuSelectedBackground(), "MenuItem.selectionForeground", getMenuSelectedForeground(), "Panel.background", new ColorUIResource(getControl()), + "RadioButton.disabledText", + MetalLookAndFeel.getInactiveControlTextColor(), "RadioButton.icon", new UIDefaults.LazyValue() { @@ -825,6 +827,7 @@ }, "RadioButton.focus", MetalLookAndFeel.getFocusColor(), "RadioButton.font", MetalLookAndFeel.getControlTextFont(), + "RadioButton.select", MetalLookAndFeel.getControlShadow(), "RadioButtonMenuItem.border", new MetalBorders.MenuItemBorder(), "RadioButtonMenuItem.borderPainted", Boolean.TRUE, "RadioButtonMenuItem.checkIcon", Index: javax/swing/plaf/metal/MetalRadioButtonUI.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/metal/MetalRadioButtonUI.java,v retrieving revision 1.3 diff -u -r1.3 MetalRadioButtonUI.java --- javax/swing/plaf/metal/MetalRadioButtonUI.java 2 Jul 2005 20:32:51 -0000 1.3 +++ javax/swing/plaf/metal/MetalRadioButtonUI.java 6 Sep 2005 20:58:00 -0000 @@ -38,18 +38,37 @@ package javax.swing.plaf.metal; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Rectangle; + +import javax.swing.AbstractButton; import javax.swing.JComponent; +import javax.swing.JRadioButton; +import javax.swing.UIDefaults; +import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; import javax.swing.plaf.basic.BasicRadioButtonUI; + +/** + * A UI delegate for the [EMAIL PROTECTED] JRadioButton} component under the + * [EMAIL PROTECTED] MetalLookAndFeel}. + */ public class MetalRadioButtonUI extends BasicRadioButtonUI { - // FIXME: maybe replace by a Map of instances when this becomes stateful - /** The shared UI instance for JRadioButtons. */ - private static MetalRadioButtonUI instance = null; - + /** Used to draw the focus rectangle. */ + protected Color focusColor; + + /** Used to fill the icon when the button is pressed. */ + protected Color selectColor; + + /** Used to draw disabled text. */ + protected Color disabledTextColor; + /** * Constructs a new instance of MetalRadioButtonUI. */ @@ -67,8 +86,102 @@ */ public static ComponentUI createUI(JComponent component) { - if (instance == null) - instance = new MetalRadioButtonUI(); - return instance; + return new MetalRadioButtonUI(); + } + + /** + * Sets the default values for the specified button. + * + * @param b the button. + */ + public void installDefaults(AbstractButton b) + { + super.installDefaults(b); + UIDefaults defaults = UIManager.getLookAndFeelDefaults(); + disabledTextColor = defaults.getColor("RadioButton.disabledText"); + focusColor = defaults.getColor("RadioButton.focus"); + selectColor = defaults.getColor("RadioButton.select"); + } + + /** + * Clears any defaults set in the installDefaults() method. + * + * @param b the [EMAIL PROTECTED] JRadioButton}. + */ + protected void uninstallDefaults(AbstractButton b) + { + super.uninstallDefaults(b); + disabledTextColor = null; + focusColor = null; + selectColor = null; + } + + /** + * Returns the color used to fill the [EMAIL PROTECTED] JRadioButton}'s icon when the + * button is pressed. The default color is obtained from the + * [EMAIL PROTECTED] UIDefaults} via an entry with the key + * <code>RadioButton.select</code>. + * + * @return The select color. + */ + protected Color getSelectColor() + { + return selectColor; + } + + /** + * Returns the color for the [EMAIL PROTECTED] JRadioButton}'s text when the button is + * disabled. The default color is obtained from the [EMAIL PROTECTED] UIDefaults} via + * an entry with the key <code>RadioButton.disabledText</code>. + * + * @return The disabled text color. + */ + protected Color getDisabledTextColor() + { + return disabledTextColor; + } + + /** + * Returns the color used to draw the focus rectangle when the + * [EMAIL PROTECTED] JRadioButton} has the focus. The default color is obtained from + * the [EMAIL PROTECTED] UIDefaults} via an entry with the key + * <code>RadioButton.focus</code>. + * + * @return The color used to draw the focus rectangle. + * + * @see #paintFocus(Graphics, Rectangle, Dimension) + */ + protected Color getFocusColor() + { + return focusColor; + } + + /** + * Paints the [EMAIL PROTECTED] JRadioButton}. + * + * @param g the graphics device. + * @param c the component (an instance of [EMAIL PROTECTED] JRadioButton}). + */ + public void paint(Graphics g, JComponent c) + { + super.paint(g, c); + // FIXME: disabled text isn't being drawn correctly, it's possible that + // it could be done here... + } + + /** + * Paints the focus rectangle for the [EMAIL PROTECTED] JRadioButton}. + * + * @param g the graphics device. + * @param t the bounding rectangle for the text. + * @param d ??? + */ + protected void paintFocus(Graphics g, Rectangle t, Dimension d) + { + g.setColor(focusColor); + g.drawRect(t.x, t.y, t.width, t.height); + // FIXME: we seem to be drawing too tight a rectangle here, perhaps there + // is some padding to do somewhere??? } + }
_______________________________________________ Classpath-patches mailing list Classpath-patches@gnu.org http://lists.gnu.org/mailman/listinfo/classpath-patches