55 |
import javax.swing.UIManager; |
import javax.swing.UIManager; |
56 |
import javax.swing.plaf.ButtonUI; |
import javax.swing.plaf.ButtonUI; |
57 |
import javax.swing.plaf.ComponentUI; |
import javax.swing.plaf.ComponentUI; |
58 |
|
import javax.swing.plaf.UIResource; |
59 |
|
|
60 |
public class BasicButtonUI extends ButtonUI |
public class BasicButtonUI extends ButtonUI |
61 |
{ |
{ |
123 |
{ |
{ |
124 |
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); |
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); |
125 |
String prefix = getPropertyPrefix(); |
String prefix = getPropertyPrefix(); |
126 |
|
b.setFont(defaults.getFont(prefix + "font")); |
127 |
focusColor = defaults.getColor(prefix + "focus"); |
focusColor = defaults.getColor(prefix + "focus"); |
128 |
b.setForeground(defaults.getColor(prefix + "foreground")); |
b.setForeground(defaults.getColor(prefix + "foreground")); |
129 |
b.setBackground(defaults.getColor(prefix + "background")); |
b.setBackground(defaults.getColor(prefix + "background")); |
132 |
b.setIconTextGap(defaults.getInt(prefix + "textIconGap")); |
b.setIconTextGap(defaults.getInt(prefix + "textIconGap")); |
133 |
b.setInputMap(JComponent.WHEN_FOCUSED, |
b.setInputMap(JComponent.WHEN_FOCUSED, |
134 |
(InputMap) defaults.get(prefix + "focusInputMap")); |
(InputMap) defaults.get(prefix + "focusInputMap")); |
135 |
|
b.setRolloverEnabled(defaults.getBoolean(prefix + "rollover")); |
136 |
b.setOpaque(true); |
b.setOpaque(true); |
137 |
} |
} |
138 |
|
|
139 |
protected void uninstallDefaults(AbstractButton b) |
protected void uninstallDefaults(AbstractButton b) |
140 |
{ |
{ |
141 |
|
if (b.getFont() instanceof UIResource) |
142 |
|
b.setFont(null); |
143 |
b.setForeground(null); |
b.setForeground(null); |
144 |
b.setBackground(null); |
b.setBackground(null); |
145 |
b.setBorder(null); |
b.setBorder(null); |
269 |
|
|
270 |
g.setFont(f); |
g.setFont(f); |
271 |
|
|
272 |
SwingUtilities.calculateInnerArea(b, vr); |
if (b.isBorderPainted()) |
273 |
|
SwingUtilities.calculateInnerArea(b, vr); |
274 |
|
else |
275 |
|
vr = SwingUtilities.getLocalBounds(b); |
276 |
String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f), |
String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f), |
277 |
b.getText(), |
b.getText(), |
278 |
currentIcon(b), |
currentIcon(b), |
409 |
|
|
410 |
if (b.isEnabled()) |
if (b.isEnabled()) |
411 |
{ |
{ |
412 |
g.setColor(b.getForeground()); |
g.setColor(b.getForeground()); |
413 |
g.drawString(text, textRect.x, textRect.y + fm.getAscent()); |
g.drawString(text, textRect.x, textRect.y + fm.getAscent()); |
414 |
} |
} |
415 |
else |
else |
416 |
{ |
{ |
417 |
g.setColor(b.getBackground().brighter()); |
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); |
418 |
g.drawString(text, textRect.x, textRect.y + fm.getAscent()); |
String prefix = getPropertyPrefix(); |
419 |
g.setColor(b.getBackground().darker()); |
g.setColor(defaults.getColor(prefix + "disabledText")); |
420 |
g.drawString(text, textRect.x + 1, textRect.y + fm.getAscent() + 1); |
g.drawString(text, textRect.x, textRect.y + fm.getAscent()); |
421 |
} |
} |
422 |
} |
} |
423 |
} |
} |