Java Code Examples for javax.swing.AbstractButton#getForeground()

The following examples show how to use javax.swing.AbstractButton#getForeground() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LuckButtonUI.java    From littleluck with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 2
Source File: FlatSlidingButtonUI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@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);
    }
}
 
Example 3
Source File: WinUtils.java    From beautyeye with Apache License 2.0 4 votes vote down vote up
/**
	 * 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的兼容性
			
		}
	}