47 |
import javax.swing.AbstractButton; |
import javax.swing.AbstractButton; |
48 |
import javax.swing.JComponent; |
import javax.swing.JComponent; |
49 |
import javax.swing.JToggleButton; |
import javax.swing.JToggleButton; |
50 |
|
import javax.swing.SwingConstants; |
51 |
import javax.swing.SwingUtilities; |
import javax.swing.SwingUtilities; |
|
import javax.swing.UIDefaults; |
|
52 |
import javax.swing.UIManager; |
import javax.swing.UIManager; |
53 |
import javax.swing.plaf.ComponentUI; |
import javax.swing.plaf.ComponentUI; |
54 |
import javax.swing.plaf.basic.BasicButtonUI; |
import javax.swing.plaf.basic.BasicButtonUI; |
131 |
public void installDefaults(AbstractButton b) |
public void installDefaults(AbstractButton b) |
132 |
{ |
{ |
133 |
super.installDefaults(b); |
super.installDefaults(b); |
134 |
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); |
focusColor = UIManager.getColor(getPropertyPrefix() + "focus"); |
135 |
focusColor = defaults.getColor(getPropertyPrefix() + "focus"); |
selectColor = UIManager.getColor(getPropertyPrefix() + "select"); |
136 |
selectColor = defaults.getColor(getPropertyPrefix() + "select"); |
disabledTextColor = UIManager.getColor(getPropertyPrefix() + "disabledText"); |
|
disabledTextColor = defaults.getColor(getPropertyPrefix() + "disabledText"); |
|
137 |
} |
} |
138 |
|
|
139 |
/** |
/** |
199 |
g.drawRect(fr.x - 1, fr.y - 1, fr.width + 1, fr.height + 1); |
g.drawRect(fr.x - 1, fr.y - 1, fr.width + 1, fr.height + 1); |
200 |
g.setColor(saved); |
g.setColor(saved); |
201 |
} |
} |
202 |
|
|
203 |
|
/** |
204 |
|
* If the property <code>ToggleButton.gradient</code> is set, then a gradient |
205 |
|
* is painted as background, otherwise the normal superclass behaviour is |
206 |
|
* called. |
207 |
|
*/ |
208 |
|
public void update(Graphics g, JComponent c) |
209 |
|
{ |
210 |
|
if (c.isOpaque() && UIManager.get(getPropertyPrefix() + "gradient") != null) |
211 |
|
{ |
212 |
|
MetalUtils.paintGradient(g, 0, 0, c.getWidth(), c.getHeight(), |
213 |
|
SwingConstants.VERTICAL, |
214 |
|
getPropertyPrefix() + "gradient"); |
215 |
|
paint(g, c); |
216 |
|
} |
217 |
|
else |
218 |
|
super.update(g, c); |
219 |
|
} |
220 |
|
|
221 |
} |
} |