本文整理了Java中java.awt.Window.getFocusOwner()
方法的一些代码示例,展示了Window.getFocusOwner()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.getFocusOwner()
方法的具体详情如下:
包路径:java.awt.Window
类名称:Window
方法名:getFocusOwner
[英]Returns the child Component of this Window that has focus if this Window is focused; returns null otherwise.
[中]如果此窗口已聚焦,则返回此窗口中具有聚焦的子组件;否则返回null。
代码示例来源:origin: abbot/abbot
private static Component getFocusOwner(Window w) {
Component focus = w.getFocusOwner();
if (focus == null) {
Window[] owned = w.getOwnedWindows();
for (int i=0;i < owned.length;i++) {
if ((focus = owned[i].getFocusOwner()) != null)
return focus;
}
}
return focus;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
public void run(){
Component c = component;
if(c != null) {
java.awt.Window window = SwingUtilities.windowForComponent(c);
if(window != null) {
if(window.getFocusOwner() == c) {
if (debugCaretFocusExtra){
System.err.println("caret will remain visible, windowForComponent(c).getFocusOwner is the same as the c");
System.err.println("window.getFocusOwner:"+window.getFocusOwner());
System.err.println("component:"+c);
}
return;
}
}
}
if (debugCaretFocusExtra) {
System.err.println("going to set caret visible to: false");
}
setVisible(false);
}
});
代码示例来源:origin: joel-costigliola/assertj-swing
@RunsInCurrentThread
@Nullable private Component focusOwnerOf(@Nonnull Window w) {
if (!w.isShowing()) {
return null;
}
Component focus = w.getFocusOwner();
if (focus != null) {
return focus;
}
for (Window o : w.getOwnedWindows()) {
focus = o.getFocusOwner();
if (focus != null) {
return focus;
}
}
return null;
}
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-beans
private void enterBusy() {
myJavaHierarchyTree.setModel(pleaseWaitTreeModel);
JRootPane rootPane = SwingUtilities.getRootPane(CDIPanel.this);
if (rootPane != null) {
rootPane.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
Window window = SwingUtilities.getWindowAncestor(this);
if (window != null) {
myLastFocusedComponent = window.getFocusOwner();
}
myFilterTextField.setEnabled(false);
myCaseSensitiveFilterCheckBox.setEnabled(false);
myShowFQNToggleButton.setEnabled(false);
myExpandAllButton.setEnabled(false);
}
代码示例来源:origin: freeplane/freeplane
private void focusSelectedNode(final Window newWindow, int counter) {
if(counter > 0) {
SwingUtilities.invokeLater(() -> focusSelectedNode(newWindow, counter - 1));
return;
}
final MapView mapView = getMapView();
if(mapView == null || SwingUtilities.getWindowAncestor(mapView) != newWindow)
return;
final NodeView selectedNode = mapView.getSelected();
if(selectedNode == null)
return;
final Component focusOwner = newWindow.getFocusOwner();
if(focusOwner == null)
return;
final Container nodeView = SwingUtilities.getAncestorOfClass(NodeView.class, focusOwner);
if (nodeView != null && nodeView != selectedNode)
selectedNode.requestFocusInWindow();
}
代码示例来源:origin: chatty/chatty
@Override
public void actionPerformed(ActionEvent e) {
if (parent.getFocusOwner().getClass() == JTextField.class) {
return;
}
if (!combo.isPopupVisible() && combo.getSelectedIndex() != 0) {
combo.setSelectedIndex(0);
}
combo.requestFocusInWindow();
combo.setPopupVisible(!combo.isPopupVisible());
}
});
代码示例来源:origin: org.jclarion/clarion-runtime
Component focus=null;
if (c instanceof Window) {
focus=((Window)c).getFocusOwner();
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
@Override
public void doIt(final View view) {
URIChooser fileChooser = getChooser(view);
Window wAncestor = SwingUtilities.getWindowAncestor(view.getComponent());
final Component oldFocusOwner = (wAncestor == null) ? null : wAncestor.getFocusOwner();
JSheet.showOpenSheet(fileChooser, view.getComponent(), new SheetListener() {
@Override
public void optionSelected(final SheetEvent evt) {
if (evt.getOption() == JFileChooser.APPROVE_OPTION) {
final URI uri;
if ((evt.getChooser() instanceof JFileURIChooser) && evt.getFileChooser().getFileFilter() instanceof ExtensionFileFilter) {
uri = ((ExtensionFileFilter) evt.getFileChooser().getFileFilter()).makeAcceptable(evt.getFileChooser().getSelectedFile()).toURI();
} else {
uri = evt.getChooser().getSelectedURI();
}
loadViewFromURI(view, uri, evt.getChooser());
} else {
view.setEnabled(true);
if (oldFocusOwner != null) {
oldFocusOwner.requestFocus();
}
}
}
});
}
代码示例来源:origin: stackoverflow.com
focusIndex = fieldList.indexOf(getFocusOwner());
System.out.println(focusIndex);
代码示例来源:origin: net.sf.squirrel-sql/squirrel-sql
public void widgetActivated(WidgetEvent evt)
{
Window window = SwingUtilities.windowForComponent(ObjectTreeInternalFrame.this.getObjectTreePanel());
Component focusOwner = (window != null) ? window.getFocusOwner() : null;
if (focusOwner != null)
{
FocusEvent lost = new FocusEvent(focusOwner, FocusEvent.FOCUS_LOST);
FocusEvent gained = new FocusEvent(focusOwner, FocusEvent.FOCUS_GAINED);
window.dispatchEvent(lost);
window.dispatchEvent(gained);
window.dispatchEvent(lost);
focusOwner.requestFocus();
}
}
});
代码示例来源:origin: realXuJiang/bigtable-sql
public void widgetActivated(WidgetEvent evt)
{
Window window = SwingUtilities.windowForComponent(ObjectTreeInternalFrame.this.getObjectTreePanel());
Component focusOwner = (window != null) ? window.getFocusOwner() : null;
if (focusOwner != null)
{
FocusEvent lost = new FocusEvent(focusOwner, FocusEvent.FOCUS_LOST);
FocusEvent gained = new FocusEvent(focusOwner, FocusEvent.FOCUS_GAINED);
window.dispatchEvent(lost);
window.dispatchEvent(gained);
window.dispatchEvent(lost);
focusOwner.requestFocus();
}
}
});
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
@Override
public void actionPerformed(ActionEvent evt) {
final View view = (View) getActiveView();
if (view.isEnabled()) {
ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.app.Labels");
oldFocusOwner = SwingUtilities.getWindowAncestor(view.getComponent()).getFocusOwner();
view.setEnabled(false);
URIChooser fileChooser = getApplication().getExportChooser(view);
JSheet.showSheet(fileChooser, view.getComponent(), labels.getString("filechooser.export"), new SheetListener() {
@Override
public void optionSelected(final SheetEvent evt) {
if (evt.getOption() == JFileChooser.APPROVE_OPTION) {
final URI uri = evt.getChooser().getSelectedURI();
if (evt.getChooser()instanceof JFileURIChooser) {
exportView(view, uri, evt.getChooser());
} else {
exportView(view, uri, null);
}
} else {
view.setEnabled(true);
if (oldFocusOwner != null) {
oldFocusOwner.requestFocus();
}
}
}
});
}
}
代码示例来源:origin: net.sf.cuf/cuf-swing
if (pEnabled && !glassPane.isVisible())
mLastFocusOwner= target.getFocusOwner();
mLastCursor = target.getCursor();
target.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
oldFocusOwner = SwingUtilities.getWindowAncestor(view.getComponent()).getFocusOwner();
view.setEnabled(false);
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
protected void reviewChanges() {
if (unsavedView.isEnabled()) {
final ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.app.Labels");
oldFocusOwner = SwingUtilities.getWindowAncestor(unsavedView.getComponent()).getFocusOwner();
unsavedView.setEnabled(false);
URI unsavedURI = unsavedView.getURI();
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
oldFocusOwner = owner.getFocusOwner();
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
oldFocusOwner = SwingUtilities.getWindowAncestor(unsavedView.getComponent()).getFocusOwner();
unsavedView.setEnabled(false);
JOptionPane pane = new JOptionPane(
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
final ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.app.Labels");
Window wAncestor = SwingUtilities.getWindowAncestor(v.getComponent());
oldFocusOwner = (wAncestor == null) ? null : wAncestor.getFocusOwner();
v.setEnabled(false);
代码示例来源:origin: org.jclarion/clarion-runtime
} else {
if (c instanceof Window) {
f = ((Window)c).getFocusOwner();
代码示例来源:origin: net.sourceforge.mydoggy/mydoggy-plaf
Component focusOwner = oldWindow.getWindow().getFocusOwner();
oldWindow.setVisible(false);
oldWindow.getWindow().removeMouseMotionListener(resizeMouseInputHandler);
内容来源于网络,如有侵权,请联系作者删除!