107 |
textShiftOffset = defaultTextShiftOffset; |
textShiftOffset = defaultTextShiftOffset; |
108 |
} |
} |
109 |
|
|
110 |
|
/** |
111 |
|
* Returns the prefix for the UI defaults property for this UI class. |
112 |
|
* This is 'Button' for this class. |
113 |
|
* |
114 |
|
* @return the prefix for the UI defaults property |
115 |
|
*/ |
116 |
|
protected String getPropertyPrefix() |
117 |
|
{ |
118 |
|
return "Button"; |
119 |
|
} |
120 |
|
|
121 |
protected void installDefaults(AbstractButton b) |
protected void installDefaults(AbstractButton b) |
122 |
{ |
{ |
123 |
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); |
UIDefaults defaults = UIManager.getLookAndFeelDefaults(); |
124 |
focusColor = defaults.getColor("Button.focus"); |
String prefix = getPropertyPrefix(); |
125 |
b.setForeground(defaults.getColor("Button.foreground")); |
focusColor = defaults.getColor(prefix + ".focus"); |
126 |
b.setBackground(defaults.getColor("Button.background")); |
b.setForeground(defaults.getColor(prefix + ".foreground")); |
127 |
b.setMargin(defaults.getInsets("Button.margin")); |
b.setBackground(defaults.getColor(prefix + ".background")); |
128 |
b.setBorder(defaults.getBorder("Button.border")); |
b.setMargin(defaults.getInsets(prefix + ".margin")); |
129 |
b.setIconTextGap(defaults.getInt("Button.textIconGap")); |
b.setBorder(defaults.getBorder(prefix + ".border")); |
130 |
|
b.setIconTextGap(defaults.getInt(prefix + ".textIconGap")); |
131 |
b.setInputMap(JComponent.WHEN_FOCUSED, |
b.setInputMap(JComponent.WHEN_FOCUSED, |
132 |
(InputMap) defaults.get("Button.focusInputMap")); |
(InputMap) defaults.get(prefix + ".focusInputMap")); |
133 |
b.setOpaque(true); |
b.setOpaque(true); |
134 |
} |
} |
135 |
|
|
259 |
Rectangle tr = new Rectangle(); |
Rectangle tr = new Rectangle(); |
260 |
Rectangle ir = new Rectangle(); |
Rectangle ir = new Rectangle(); |
261 |
Rectangle vr = new Rectangle(); |
Rectangle vr = new Rectangle(); |
|
Rectangle br = new Rectangle(); |
|
262 |
|
|
263 |
Font f = c.getFont(); |
Font f = c.getFont(); |
264 |
|
|
265 |
g.setFont(f); |
g.setFont(f); |
266 |
|
|
267 |
SwingUtilities.calculateInnerArea(b, br); |
SwingUtilities.calculateInnerArea(b, vr); |
|
SwingUtilities.calculateInsetArea(br, b.getMargin(), vr); |
|
268 |
String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f), |
String text = SwingUtilities.layoutCompoundLabel(c, g.getFontMetrics(f), |
269 |
b.getText(), |
b.getText(), |
270 |
currentIcon(b), |
currentIcon(b), |
280 |
|| b.isSelected()) |
|| b.isSelected()) |
281 |
paintButtonPressed(g, b); |
paintButtonPressed(g, b); |
282 |
else |
else |
283 |
paintButtonNormal(g, br, c); |
paintButtonNormal(g, vr, c); |
284 |
|
|
285 |
paintIcon(g, c, ir); |
paintIcon(g, c, ir); |
286 |
if (text != null) |
if (text != null) |