本文整理汇总了Java中javax.swing.JComponent.isFocusOwner方法的典型用法代码示例。如果您正苦于以下问题:Java JComponent.isFocusOwner方法的具体用法?Java JComponent.isFocusOwner怎么用?Java JComponent.isFocusOwner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComponent
的用法示例。
在下文中一共展示了JComponent.isFocusOwner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintBorder
import javax.swing.JComponent; //导入方法依赖的package包/类
/**
* Draws the border of the combobox.
*/
private void paintBorder(Graphics g, JComponent c) {
int w = c.getWidth();
int h = c.getHeight();
if (w <= 0 || h <= 0) {
return;
}
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
boolean hasFocus = comboBox.isEditable() ? c.isFocusOwner()
|| ((JComboBox) c).getEditor().getEditorComponent().isFocusOwner() : c.isFocusOwner();
if (c.isEnabled()) {
if (hasFocus) {
g2.setColor(Colors.COMBOBOX_BORDER_FOCUS);
} else {
g2.setColor(Colors.COMBOBOX_BORDER);
}
} else {
g2.setColor(Colors.COMBOBOX_BORDER_DISABLED);
}
g2.drawRoundRect(0, 0, w - 1, h - 1, RapidLookAndFeel.CORNER_DEFAULT_RADIUS, RapidLookAndFeel.CORNER_DEFAULT_RADIUS);
}