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

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

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

revision 1.3.2.4 by gnu_andrew, Wed Nov 2 00:44:00 2005 UTC revision 1.3.2.5 by gnu_andrew, Sun Nov 27 21:00:41 2005 UTC
# Line 47  import java.awt.Rectangle; Line 47  import java.awt.Rectangle;
47  import javax.swing.AbstractButton;  import javax.swing.AbstractButton;
48  import javax.swing.JButton;  import javax.swing.JButton;
49  import javax.swing.JComponent;  import javax.swing.JComponent;
50  import javax.swing.UIDefaults;  import javax.swing.SwingConstants;
51  import javax.swing.UIManager;  import javax.swing.UIManager;
52  import javax.swing.plaf.ComponentUI;  import javax.swing.plaf.ComponentUI;
53  import javax.swing.plaf.UIResource;  import javax.swing.plaf.UIResource;
# Line 78  public class MetalButtonUI Line 78  public class MetalButtonUI
78    public MetalButtonUI()    public MetalButtonUI()
79    {    {
80      super();      super();
81      UIDefaults def = UIManager.getLookAndFeelDefaults();      focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
82      focusColor = def.getColor(getPropertyPrefix() + "focus");      selectColor = UIManager.getColor(getPropertyPrefix() + "select");
83      selectColor = def.getColor(getPropertyPrefix() + "select");      disabledTextColor = UIManager.getColor(getPropertyPrefix() + "disabledText");
     disabledTextColor = def.getColor(getPropertyPrefix() + "disabledText");  
84    }    }
85    
86    /**    /**
# Line 135  public class MetalButtonUI Line 134  public class MetalButtonUI
134    public void installDefaults(AbstractButton button)    public void installDefaults(AbstractButton button)
135    {    {
136      super.installDefaults(button);      super.installDefaults(button);
137      if (button.isRolloverEnabled())      button.setRolloverEnabled(UIManager.getBoolean(
138        {                                              getPropertyPrefix() + "rollover"));
         if (button.getBorder() instanceof UIResource)  
           button.setBorder(MetalBorders.getRolloverBorder());  
       }  
139    }    }
140            
141    /**    /**
# Line 148  public class MetalButtonUI Line 144  public class MetalButtonUI
144    public void uninstallDefaults(AbstractButton button)    public void uninstallDefaults(AbstractButton button)
145    {    {
146      super.uninstallDefaults(button);      super.uninstallDefaults(button);
147      if (button.getBorder() instanceof UIResource)      button.setRolloverEnabled(false);
       button.setBorder(null);  
148    }    }
149    
150    /**    /**
# Line 192  public class MetalButtonUI Line 187  public class MetalButtonUI
187     */     */
188    protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect,    protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect,
189            Rectangle textRect, Rectangle iconRect) {            Rectangle textRect, Rectangle iconRect) {
190      if (b.hasFocus() && b.isFocusPainted())      if (b.isEnabled() && b.hasFocus() && b.isFocusPainted())
191      {      {
192        Color savedColor = g.getColor();        Color savedColor = g.getColor();
193        g.setColor(getFocusColor());        g.setColor(getFocusColor());
194        Rectangle focusRect = iconRect.union(textRect);        Rectangle focusRect = iconRect.union(textRect);
195        g.drawRect(focusRect.x - 1, focusRect.y - 1,        g.drawRect(focusRect.x - 1, focusRect.y,
196                   focusRect.width + 1, focusRect.height + 1);                   focusRect.width + 1, focusRect.height);
197        g.setColor(savedColor);        g.setColor(savedColor);
198      }      }
199    }    }
# Line 230  public class MetalButtonUI Line 225  public class MetalButtonUI
225          g.drawString(text, textRect.x, textRect.y + fm.getAscent());          g.drawString(text, textRect.x, textRect.y + fm.getAscent());
226        }          }  
227    }    }
228    
229      /**
230       * If the property <code>Button.gradient</code> is set, then a gradient is
231       * painted as background, otherwise the normal superclass behaviour is
232       * called.
233       */
234      public void update(Graphics g, JComponent c)
235      {
236        AbstractButton b = (AbstractButton) c;
237        if (b.isOpaque() && UIManager.get(getPropertyPrefix() + "gradient") != null
238            && !b.getModel().isPressed() && b.isEnabled())
239          {
240            MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(),
241                                     SwingConstants.VERTICAL,
242                                     getPropertyPrefix() + "gradient");
243            paint(g, c);
244          }
245        else
246          super.update(g, c);
247      }
248  }  }

Legend:
Removed from v.1.3.2.4  
changed lines
  Added in v.1.3.2.5

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