下面列出了javax.swing.AbstractButton#getForeground ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void installDefaults(AbstractButton b)
{
super.installDefaults(b);
LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE);
LookAndFeel.installProperty(b, "opaque", Boolean.FALSE);
btnColorInfo = (LuckButtonColorInfo) UIManager.get(LuckButtonUIBundle.COLOR_INFO);
// 使用配置颜色替换默认字体颜色
// Replace the default font color with the configured color
if(b.getForeground() instanceof ColorUIResource)
{
b.setForeground(btnColorInfo.getFontColor());
}
listener = new ButtonPropertyChangeListener();
b.addPropertyChangeListener(listener);
}
@Override
protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
if (((SlidingButton) b).isBlinkState()) {
Color oldForeground = b.getForeground();
b.setForeground(attentionForeground);
super.paintText(g, b, textRect, text);
b.setForeground(oldForeground);
} else {
super.paintText(g, b, textRect, text);
}
}
/**
* Paint classic text.
*
* @param b the b
* @param g the g
* @param x the x
* @param y the y
* @param text the text
* @param mnemIndex the mnem index
*/
static void paintClassicText(AbstractButton b, Graphics g, int x, int y,
String text, int mnemIndex) {
ButtonModel model = b.getModel();
/* Draw the Text */
Color color = b.getForeground();
if(model.isEnabled()) {
/*** paint the text normally */
if(!(b instanceof JMenuItem && model.isArmed())
&& !(b instanceof JMenu && (model.isSelected() || model.isRollover()))) {
/* We shall not set foreground color for selected menu or
* armed menuitem. Foreground must be set in appropriate
* Windows* class because these colors passes from
* BasicMenuItemUI as protected fields and we can't
* reach them from this class */
g.setColor(b.getForeground());
}
// SwingUtilities2.drawStringUnderlineCharAt(b, g,text, mnemIndex, x, y);
MySwingUtilities2.drawStringUnderlineCharAt(b
, g,text, mnemIndex, x, y);//* modified by Jack Jiang 为了非公开api的兼容性
} else { /*** paint the text disabled ***/
color = UIManager.getColor("Button.shadow");
Color shadow = UIManager.getColor("Button.disabledShadow");
if(model.isArmed()) {
color = UIManager.getColor("Button.disabledForeground");
} else {
if (shadow == null) {
shadow = b.getBackground().darker();
}
g.setColor(shadow);
// SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex,
// x + 1, y + 1);
MySwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex,
x + 1, y + 1);//* modified by Jack Jiang 为了非公开api的兼容性
}
if (color == null) {
color = b.getBackground().brighter();
}
g.setColor(color);
// SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex, x, y);
MySwingUtilities2.drawStringUnderlineCharAt(
b, g, text, mnemIndex, x, y);//* modified by Jack Jiang 为了非公开api的兼容性
}
}