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.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; |
229 |
g.drawString(text, textRect.x, textRect.y + fm.getAscent()); |
g.drawString(text, textRect.x, textRect.y + fm.getAscent()); |
230 |
} |
} |
231 |
} |
} |
232 |
|
|
233 |
|
/** |
234 |
|
* If the property <code>Button.gradient</code> is set, then a gradient is |
235 |
|
* painted as background, otherwise the normal superclass behaviour is |
236 |
|
* called. |
237 |
|
*/ |
238 |
|
public void update(Graphics g, JComponent c) |
239 |
|
{ |
240 |
|
if (c.isOpaque() && UIManager.get(getPropertyPrefix() + "gradient") != null) |
241 |
|
{ |
242 |
|
MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(), |
243 |
|
SwingConstants.VERTICAL, |
244 |
|
getPropertyPrefix() + "gradient"); |
245 |
|
paint(g, c); |
246 |
|
} |
247 |
|
else |
248 |
|
super.update(g, c); |
249 |
|
} |
250 |
} |
} |