本文整理汇总了Java中javax.swing.AbstractButton.hasFocus方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractButton.hasFocus方法的具体用法?Java AbstractButton.hasFocus怎么用?Java AbstractButton.hasFocus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.AbstractButton
的用法示例。
在下文中一共展示了AbstractButton.hasFocus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawButtonBorder
import javax.swing.AbstractButton; //导入方法依赖的package包/类
/**
* Draws the given button border with the specified shape.
*
* @param b
* @param g
* @param shape
*/
public static void drawButtonBorder(AbstractButton b, Graphics g, Shape shape) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
if (b.isEnabled()) {
if (b.hasFocus()) {
g2.setColor(Colors.BUTTON_BORDER_FOCUS);
} else {
g2.setColor(Colors.BUTTON_BORDER);
}
} else {
g2.setColor(Colors.BUTTON_BORDER_DISABLED);
}
g2.draw(shape);
}
示例2: paint
import javax.swing.AbstractButton; //导入方法依赖的package包/类
@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));
}
}
}