本文整理汇总了Java中org.openide.windows.TopComponent.requestFocus方法的典型用法代码示例。如果您正苦于以下问题:Java TopComponent.requestFocus方法的具体用法?Java TopComponent.requestFocus怎么用?Java TopComponent.requestFocus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.windows.TopComponent
的用法示例。
在下文中一共展示了TopComponent.requestFocus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: focusSelectedTopComponent
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
@Override
public void focusSelectedTopComponent() {
// PENDING focus gets main window sometimes, investgate and refine (jdk1.4.1?).
final TopComponent selectedTopComponent = tabbedHandler.getSelectedTopComponent();
if (selectedTopComponent == null) {
return;
}
Window oldFocusedW = FocusManager.getCurrentManager().getFocusedWindow();
Window newFocusedW = SwingUtilities.getWindowAncestor(selectedTopComponent);
//#177550: Call requestFocus on selected TC only if TC is in AWT hierarchy
if (newFocusedW != null) {
if (newFocusedW.equals(oldFocusedW) || null == oldFocusedW) {
// focus transfer inside one window or system is not active in OS at all
// so requestFocusInWindow call is right and enough
selectedTopComponent.requestFocusInWindow();
} else {
// focus transfer between different windows
newFocusedW.toFront();
selectedTopComponent.requestFocus();
}
}
}
示例2: returnFocus
import org.openide.windows.TopComponent; //导入方法依赖的package包/类
private void returnFocus (boolean force) {
displayer.setVisible(false);
if (caller != null) {
TopComponent tc = caller.get();
if (tc != null) {
tc.requestActive();
tc.requestFocus();
return;
}
}
if (force) {
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
}
}