/[classpath]/classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java
ViewVC logotype

Diff of /classpath/javax/swing/plaf/metal/MetalToggleButtonUI.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.2.3 by gnu_andrew, Tue Sep 20 18:46:34 2005 UTC revision 1.1.2.4 by gnu_andrew, Wed Nov 2 00:44:01 2005 UTC
# Line 55  import javax.swing.plaf.basic.BasicButto Line 55  import javax.swing.plaf.basic.BasicButto
55  import javax.swing.plaf.basic.BasicToggleButtonUI;  import javax.swing.plaf.basic.BasicToggleButtonUI;
56    
57  /**  /**
58   * A UI delegate for {@link JToggleButton} components.   * A UI delegate for the {@link JToggleButton} component.
59   */   */
60  public class MetalToggleButtonUI  public class MetalToggleButtonUI
61    extends BasicToggleButtonUI    extends BasicToggleButtonUI
# Line 71  public class MetalToggleButtonUI Line 71  public class MetalToggleButtonUI
71    protected Color disabledTextColor;    protected Color disabledTextColor;
72    
73    /**    /**
74     * Returns an instance of MetalToggleButtonUI.     * Returns a new instance of <code>MetalToggleButtonUI</code>.
75     *     *
76     * @param component the component for which we return an UI instance     * @param component the component for which we return an UI instance
77     *     *
78     * @return an instance of MetalToggleButtonUI     * @return A new instance of <code>MetalToggleButtonUI</code>.
79     */     */
80    public static ComponentUI createUI(JComponent component)    public static ComponentUI createUI(JComponent component)
81    {    {
# Line 83  public class MetalToggleButtonUI Line 83  public class MetalToggleButtonUI
83    }    }
84    
85    /**    /**
86     * Constructs a new instance of MetalToggleButtonUI.     * Constructs a new instance of <code>MetalToggleButtonUI</code>.
87     */     */
88    public MetalToggleButtonUI()    public MetalToggleButtonUI()
89    {    {
90      super();      super();
     UIDefaults defaults = UIManager.getLookAndFeelDefaults();  
     focusColor = defaults.getColor(getPropertyPrefix() + "focus");  
     selectColor = defaults.getColor(getPropertyPrefix() + "select");  
     disabledTextColor = defaults.getColor(getPropertyPrefix() + "disabledText");  
91    }    }
92    
93    /**    /**
# Line 115  public class MetalToggleButtonUI Line 111  public class MetalToggleButtonUI
111    }    }
112    
113    /**    /**
114     * Returns the color for the text label of disabled buttons.     * Returns the color for the text label of disabled buttons.  The value
115       * is initialised in the {@link #installDefaults(AbstractButton)} method
116       * by reading the <code>ToggleButton.disabledText</code> item from the UI
117       * defaults.
118     *     *
119     * @return the color for the text label of disabled buttons     * @return The color for the text label of disabled buttons.
120     */     */
121    protected Color getDisabledTextColor()    protected Color getDisabledTextColor()
122    {    {
# Line 131  public class MetalToggleButtonUI Line 130  public class MetalToggleButtonUI
130     */     */
131    public void installDefaults(AbstractButton b)    public void installDefaults(AbstractButton b)
132    {    {
     // FIXME: for now, this override just changes the visibility of the method  
     // in the super-class, to satisfy japi...but there must be something else.  
133      super.installDefaults(b);      super.installDefaults(b);
134        UIDefaults defaults = UIManager.getLookAndFeelDefaults();
135        focusColor = defaults.getColor(getPropertyPrefix() + "focus");
136        selectColor = defaults.getColor(getPropertyPrefix() + "select");
137        disabledTextColor = defaults.getColor(getPropertyPrefix() + "disabledText");
138    }    }
139        
140    /**    /**
# Line 144  public class MetalToggleButtonUI Line 145  public class MetalToggleButtonUI
145     */     */
146    protected void paintButtonPressed(Graphics g, AbstractButton b)    protected void paintButtonPressed(Graphics g, AbstractButton b)
147    {    {
148      Color saved = g.getColor();      if (b.isContentAreaFilled() && b.isOpaque())
149      Rectangle bounds = SwingUtilities.getLocalBounds(b);        {
150      g.setColor(selectColor);          Color saved = g.getColor();
151      g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);          Rectangle bounds = SwingUtilities.getLocalBounds(b);
152      g.setColor(saved);          g.setColor(selectColor);
153            g.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
154            g.setColor(saved);
155          }
156    }    }
157        
158    /**    /**

Legend:
Removed from v.1.1.2.3  
changed lines
  Added in v.1.1.2.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26