本文整理汇总了Java中java.awt.Component.setFocusable方法的典型用法代码示例。如果您正苦于以下问题:Java Component.setFocusable方法的具体用法?Java Component.setFocusable怎么用?Java Component.setFocusable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Component
的用法示例。
在下文中一共展示了Component.setFocusable方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addImpl
import java.awt.Component; //导入方法依赖的package包/类
/** Overridden to set focusable to false for any AbstractButton
* subclasses which are added */
@Override
protected void addImpl(Component c, Object constraints, int idx) {
//issue 39896, after opening dialog from toolbar button, focus
//remains on toolbar button. Does not create an accessibility issue -
//all standard toolbar buttons are also available via the keyboard
if (c instanceof AbstractButton) {
c.setFocusable(false);
((JComponent) c).setOpaque(false);
if (isMetalLaF) {
//metal/ocean resets borders, so fix it this way
((AbstractButton) c).setBorderPainted(false);
((AbstractButton) c).setOpaque(false);
}
//This is active for GTK L&F. It should be fixed in JDK
//but it is not fixed in JDK 6.0.
if (!isMetalLaF) {
((AbstractButton) c).setMargin( emptyInsets );
}
if( null != label && c != label ) {
remove( label );
label = null;
}
} else if( c instanceof JToolBar.Separator ) {
JToolBar.Separator separator = (JToolBar.Separator)c;
if (getOrientation() == VERTICAL) {
separator.setOrientation(JSeparator.HORIZONTAL);
} else {
separator.setOrientation(JSeparator.VERTICAL);
}
}
super.addImpl (c, constraints, idx);
}
示例2: doLayout
import java.awt.Component; //导入方法依赖的package包/类
public void doLayout() {
// #216443 - disabled/invisible/JLabel toolbar components
// break left/right arrow focus traversal
for (Component component : getComponents())
component.setFocusable(isFocusableComponent(component));
super.doLayout();
}