38 |
|
|
39 |
package javax.swing.plaf.basic; |
package javax.swing.plaf.basic; |
40 |
|
|
|
import java.awt.Color; |
|
41 |
import java.awt.Dimension; |
import java.awt.Dimension; |
42 |
import java.awt.Font; |
import java.awt.Font; |
43 |
import java.awt.FontMetrics; |
import java.awt.FontMetrics; |
77 |
|
|
78 |
private int textShiftOffset; |
private int textShiftOffset; |
79 |
|
|
|
private Color focusColor; |
|
|
|
|
80 |
/** |
/** |
81 |
* Factory method to create an instance of BasicButtonUI for a given |
* Factory method to create an instance of BasicButtonUI for a given |
82 |
* {@link JComponent}, which should be an {@link AbstractButton}. |
* {@link JComponent}, which should be an {@link AbstractButton}. |
157 |
LookAndFeel.installColorsAndFont(b, prefix + "background", |
LookAndFeel.installColorsAndFont(b, prefix + "background", |
158 |
prefix + "foreground", prefix + "font"); |
prefix + "foreground", prefix + "font"); |
159 |
LookAndFeel.installBorder(b, prefix + "border"); |
LookAndFeel.installBorder(b, prefix + "border"); |
|
focusColor = UIManager.getColor(prefix + "focus"); |
|
160 |
b.setMargin(UIManager.getInsets(prefix + "margin")); |
b.setMargin(UIManager.getInsets(prefix + "margin")); |
161 |
b.setIconTextGap(UIManager.getInt(prefix + "textIconGap")); |
b.setIconTextGap(UIManager.getInt(prefix + "textIconGap")); |
162 |
b.setInputMap(JComponent.WHEN_FOCUSED, |
b.setInputMap(JComponent.WHEN_FOCUSED, |
397 |
*/ |
*/ |
398 |
protected void paintButtonPressed(Graphics g, AbstractButton b) |
protected void paintButtonPressed(Graphics g, AbstractButton b) |
399 |
{ |
{ |
400 |
if (b.isContentAreaFilled()) |
if (b.isContentAreaFilled() && b.isOpaque()) |
401 |
{ |
{ |
402 |
Rectangle area = new Rectangle(); |
Rectangle area = new Rectangle(); |
403 |
SwingUtilities.calculateInnerArea(b, area); |
SwingUtilities.calculateInnerArea(b, area); |
404 |
g.setColor(b.getBackground().darker()); |
g.setColor(UIManager.getColor(getPropertyPrefix() + "shadow")); |
405 |
g.fillRect(area.x, area.y, area.width, area.height); |
g.fillRect(area.x, area.y, area.width, area.height); |
406 |
} |
} |
407 |
} |
} |