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

The following examples show how to use javax.swing.AbstractButton#isBorderPainted() . 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: RapidLookTools.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Drasw a button in a toolbar.
 *
 * @param b
 *            the button
 * @param g
 *            the graphics instance
 */
public static void drawToolbarButton(Graphics g, AbstractButton b) {
	if (!b.isEnabled()) {
		return;
	}

	if (b.getModel().isSelected() && b.isRolloverEnabled() || b.getModel().isPressed() && b.getModel().isArmed()
			&& b.isRolloverEnabled()) {
		if (b.isContentAreaFilled()) {
			drawButton(b, g, createShapeForButton(b));
		}
		if (b.isBorderPainted()) {
			drawButtonBorder(b, g, createBorderShapeForButton(b));
		}
	} else if (b.getModel().isRollover() && b.isRolloverEnabled()) {
		if (b.isBorderPainted()) {
			drawButtonBorder(b, g, createBorderShapeForButton(b));
		}
	}
}
 
Example 2
Source File: ButtonUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void paint(Graphics g, JComponent c) {
	AbstractButton b = (AbstractButton) c;
	if (RapidLookTools.isToolbarButton(b)) {
		RapidLookTools.drawToolbarButton(g, b);
		super.paint(g, c);
		return;
	}

	int w = c.getWidth();
	int h = c.getHeight();
	if (w <= 0 || h <= 0) {
		return;
	}

	if (b.isContentAreaFilled()) {
		RapidLookTools.drawButton(b, g, RapidLookTools.createShapeForButton(b));
	}
	if (b.isBorderPainted()) {
		RapidLookTools.drawButtonBorder(b, g, RapidLookTools.createBorderShapeForButton(b));
	}
	super.paint(g, c);
}
 
Example 3
Source File: ButtonUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
	if (b.isBorderPainted()) {
		RapidLookTools.drawButtonBorder(b, g, RapidLookTools.createBorderShapeForButton(b));
	}
}
 
Example 4
Source File: ToggleButtonUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void paint(Graphics g, JComponent c) {
	AbstractButton b = (AbstractButton) c;

	Dimension size = b.getSize();
	FontMetrics fm = g.getFontMetrics();

	Insets i = c.getInsets();

	Rectangle viewRect = new Rectangle(size);

	viewRect.x += i.left;
	viewRect.y += i.top;
	viewRect.width -= i.right + viewRect.x;
	viewRect.height -= i.bottom + viewRect.y;

	Rectangle iconRect = new Rectangle();
	Rectangle textRect = new Rectangle();

	Font f = c.getFont();
	g.setFont(f);

	String text = SwingUtilities.layoutCompoundLabel(c, fm, b.getText(), b.getIcon(), b.getVerticalAlignment(),
			b.getHorizontalAlignment(), b.getVerticalTextPosition(), b.getHorizontalTextPosition(), viewRect, iconRect,
			textRect, b.getText() == null ? 0 : b.getIconTextGap());

	g.setColor(b.getBackground());

	if (b.isContentAreaFilled()) {
		if (RapidLookTools.isToolbarButton(b)) {
			RapidLookTools.drawToolbarButton(g, b);
		} else {
			RapidLookTools.drawButton(b, g, RapidLookTools.createShapeForButton(b));
		}
	}

	if (b.getIcon() != null) {
		paintIcon(g, b, iconRect);
	}

	if (text != null && !text.equals("")) {
		View v = (View) c.getClientProperty(BasicHTML.propertyKey);
		if (v != null) {
			v.paint(g, textRect);
		} else {
			paintText(g, b, textRect, text);
		}
	}

	if (b.isFocusPainted() && b.hasFocus()) {
		paintFocus(g, b, viewRect, textRect, iconRect);
	}

	if (!RapidLookTools.isToolbarButton(b)) {
		if (b.isBorderPainted()) {
			RapidLookTools.drawButtonBorder(b, g, RapidLookTools.createBorderShapeForButton(b));
		}
	}
}
 
Example 5
Source File: ToggleButtonUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
	if (b.isBorderPainted()) {
		RapidLookTools.drawButtonBorder(b, g, RapidLookTools.createBorderShapeForButton(b));
	}
}