本文整理了Java中javax.swing.AbstractButton.getForeground()
方法的一些代码示例,展示了AbstractButton.getForeground()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractButton.getForeground()
方法的具体详情如下:
包路径:javax.swing.AbstractButton
类名称:AbstractButton
方法名:getForeground
暂无
代码示例来源:origin: ron190/jsql-injection
g.setColor( MetalLookAndFeel.getMenuSelectedForeground() );
} else {
g.setColor( b.getForeground() );
代码示例来源:origin: com.jidesoft/jide-oss
protected Color getForegroundOfState(AbstractButton b) {
int state = JideSwingUtilities.getButtonState(b);
Color foreground = null;
if (b instanceof ComponentStateSupport) {
foreground = ((ComponentStateSupport) b).getForegroundOfState(state);
}
if (foreground == null || foreground instanceof UIResource) {
foreground = b.getForeground();
}
return foreground;
}
代码示例来源:origin: ru.sbtqa/monte-media
@Override
protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) {
AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel();
FontMetrics fm = g.getFontMetrics();
/* Draw the Text */
if (model.isEnabled()) {
/**
* * paint the text normally
*/
g.setColor(b.getForeground());
drawString(g, text, model.getMnemonic(),
textRect.x,
textRect.y + fm.getAscent());
} else {
/**
* * paint the text disabled **
*/
// g.setColor(getDisabledTextColor());
g.setColor(b.getForeground().brighter());
drawString(g, text, model.getMnemonic(),
textRect.x, textRect.y + fm.getAscent());
}
}
代码示例来源:origin: org.gosu-lang.gosu/gosu-lab
@Override
protected void paintText( Graphics g, AbstractButton b, Rectangle textRect, String text )
{
ButtonModel model = b.getModel();
FontMetrics fm = SwingUtilities2.getFontMetrics( b, g );
int mnemIndex = b.getDisplayedMnemonicIndex();
if( model.isEnabled() )
{
g.setColor( b.getForeground() );
}
else
{
g.setColor( UIManager.getColor( "Button.disabledForeground" ) );
}
SwingUtilities2.drawStringUnderlineCharAt( b, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent() );
}
}
代码示例来源:origin: org.netbeans.api/org-netbeans-swing-plaf
return;
g.setColor (b.getForeground());
Font f = b.getFont();
if (b.isSelected()) {
代码示例来源:origin: de.sciss/submin
/**
* Paints plain text view.
*
* @param g2d graphics context
* @param label painted component
* @param text label text
*/
protected void paintText(final Graphics2D g2d, final E label, final String text) {
final FontMetrics fm = SwingUtils.getFontMetrics(label, g2d);
final ButtonModel model = label.getModel();
final boolean enabled = label.isEnabled();
final boolean sel = enabled && (model.isPressed() || model.isSelected());
final int textX = textRect.x;
final int textY = textRect.y + fm.getAscent() + (sel ? pressedShiftY : 0);
g2d.setColor(enabled ? (sel ? selectedForeground : label.getForeground()) : disabledForeground);
final int mnemonicIndex = enabled ? label.getDisplayedMnemonicIndex() : -1;
if (enabled && drawShade) {
paintShadowText(g2d, text, textX, textY);
if (mnemonicIndex >= 0 && mnemonicIndex < text.length()) {
g2d.fillRect(textX + fm.stringWidth(text.substring(0, mnemonicIndex)),
textY + fm.getDescent() - 1,
fm.charWidth(text.charAt(mnemonicIndex)), 1);
}
} else {
SwingUtils.drawStringUnderlineCharAt(g2d, text, mnemonicIndex, textX, textY);
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf
g.setColor(b.getForeground());
BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
代码示例来源:origin: com.synaptix/SynaptixSwing
/**
* As of Java 2 platform v 1.4 this method should not be used or overriden.
* Use the paintText method which takes the AbstractButton argument.
*/
protected void paintText(Graphics g, JComponent c, Rectangle textRect,
String text) {
AbstractButton b = (AbstractButton) c;
ButtonModel model = b.getModel();
FontMetrics fm = SwingUtilities2.getFontMetrics(c, g);
int mnemonicIndex = b.getDisplayedMnemonicIndex();
/* Draw the Text */
if (model.isEnabled()) {
/** * paint the text normally */
g.setColor(b.getForeground());
SwingUtilities2.drawStringUnderlineCharAt(c, g, text,
mnemonicIndex, textRect.x + getTextShiftOffset(),
textRect.y + fm.getAscent() + getTextShiftOffset());
} else {
/** * paint the text disabled ** */
g.setColor(b.getBackground().brighter());
SwingUtilities2.drawStringUnderlineCharAt(c, g, text,
mnemonicIndex, textRect.x, textRect.y + fm.getAscent());
g.setColor(b.getBackground().darker());
SwingUtilities2.drawStringUnderlineCharAt(c, g, text,
mnemonicIndex, textRect.x - 1, textRect.y + fm.getAscent()
- 1);
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf
g.setColor(b.getForeground());
BasicGraphicsUtils.drawStringUnderlineCharAt(g,text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
代码示例来源:origin: Revivius/nb-darcula
protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) {
AbstractButton button = (AbstractButton) c;
ButtonModel model = button.getModel();
Color fg = button.getForeground();
if (((fg instanceof UIResource)) && ((button instanceof JButton)) && (((JButton) button).isDefaultButton())) {
Color selectedFg = UIManager.getColor("Button.darcula.selectedButtonForeground");
if (selectedFg != null) {
fg = selectedFg;
}
}
g.setColor(fg);
FontMetrics metrics = SwingUtilities2.getFontMetrics(c, g);
int mnemonicIndex = button.getDisplayedMnemonicIndex();
if (model.isEnabled()) {
SwingUtilities2.drawStringUnderlineCharAt(c, g, text, mnemonicIndex, textRect.x
+ getTextShiftOffset(), textRect.y + metrics
.getAscent() + getTextShiftOffset());
} else {
g.setColor(UIManager.getColor("Button.disabledText"));
SwingUtilities2.drawStringUnderlineCharAt(c, g, text, -1, textRect.x
+ getTextShiftOffset(), textRect.y + metrics
.getAscent() + getTextShiftOffset());
}
}
代码示例来源:origin: com.jtattoo/JTattoo
offs = 1;
Color foreground = b.getForeground();
if (foreground instanceof ColorUIResource) {
if ((model.isPressed() && model.isArmed()) || model.isSelected()) {
AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f);
g2D.setComposite(alpha);
Color fc = b.getForeground();
if (ColorHelper.getGrayValue(fc) > 164) {
fc = ColorHelper.brighter(AbstractLookAndFeel.getDisabledForegroundColor(), 40);
代码示例来源:origin: com.jtattoo/JTattoo
FontMetrics fm = JTattooUtilities.getFontMetrics(b, g, b.getFont());
if (model.isEnabled()) {
Color fc = b.getForeground();
if (AbstractLookAndFeel.getTheme().isTextShadowOn() && ColorHelper.getGrayValue(fc) > 128) {
g.setColor(Color.black);
代码示例来源:origin: com.jtattoo/JTattoo
AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
g2D.setComposite(alpha);
Color foreground = b.getForeground();
Color background = b.getBackground();
if ((model.isPressed() && model.isArmed()) || model.isSelected()) {
代码示例来源:origin: com.jtattoo/JTattoo
offs = 1;
Color foreground = b.getForeground();
Color background = b.getBackground();
if (background instanceof ColorUIResource) {
AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f);
g2D.setComposite(alpha);
Color fc = b.getForeground();
if (ColorHelper.getGrayValue(fc) > 164) {
fc = ColorHelper.brighter(AbstractLookAndFeel.getDisabledForegroundColor(), 40);
代码示例来源:origin: com.jtattoo/JTattoo
Color foreground = b.getForeground();
Color background = b.getBackground();
int offs = 0;
if (ColorHelper.getGrayValue(b.getForeground()) < 128) {
g.setColor(Color.white);
JTattooUtilities.drawStringUnderlineCharAt(b, g, text, mnemIndex, textRect.x + 1, textRect.y + 1 + fm.getAscent());
代码示例来源:origin: com.jtattoo/JTattoo
g.setColor(b.getForeground());
JTattooUtilities.drawStringUnderlineCharAt(c, g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
} else {
代码示例来源:origin: com.jtattoo/JTattoo
AlphaComposite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f);
g2D.setComposite(alpha);
Color foreground = b.getForeground();
Color background = b.getBackground();
if (background instanceof ColorUIResource) {
代码示例来源:origin: com.jtattoo/JTattoo
int mnemIndex = (JTattooUtilities.getJavaVersion() >= 1.4) ? b.getDisplayedMnemonicIndex() : JTattooUtilities.findDisplayedMnemonicIndex(b.getText(), model.getMnemonic());
if (model.isEnabled()) {
Color foreground = b.getForeground();
Color background = b.getBackground();
int offs = 0;
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/skinlf
if (model.isEnabled()) {
g.setColor(b.getForeground());
BasicGraphicsUtils.drawString(g, text, model.getMnemonic(),
textRect.x,
代码示例来源:origin: org.tentackle/tentackle-swing
if (model.isEnabled()) {
g.setColor(b.getForeground());
BasicGraphicsUtils.drawStringUnderlineCharAt(g, text,
mnemIndex, textRect.x, textRect.y + fm.getAscent());
内容来源于网络,如有侵权,请联系作者删除!