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; }
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); } });
@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; } }
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); }
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(); }
@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()); } });
Component focus=null; if (c instanceof Window) { focus=((Window)c).getFocusOwner();
@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(); } } } }); }
focusIndex = fieldList.indexOf(getFocusOwner()); System.out.println(focusIndex);
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(); } } });
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(); } } });
@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(); } } } }); } }
if (pEnabled && !glassPane.isVisible()) mLastFocusOwner= target.getFocusOwner(); mLastCursor = target.getCursor(); target.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
oldFocusOwner = SwingUtilities.getWindowAncestor(view.getComponent()).getFocusOwner(); view.setEnabled(false);
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();
oldFocusOwner = owner.getFocusOwner();
oldFocusOwner = SwingUtilities.getWindowAncestor(unsavedView.getComponent()).getFocusOwner(); unsavedView.setEnabled(false); JOptionPane pane = new JOptionPane(
final ResourceBundleUtil labels = ResourceBundleUtil.getBundle("org.jhotdraw.app.Labels"); Window wAncestor = SwingUtilities.getWindowAncestor(v.getComponent()); oldFocusOwner = (wAncestor == null) ? null : wAncestor.getFocusOwner(); v.setEnabled(false);
} else { if (c instanceof Window) { f = ((Window)c).getFocusOwner();
Component focusOwner = oldWindow.getWindow().getFocusOwner(); oldWindow.setVisible(false); oldWindow.getWindow().removeMouseMotionListener(resizeMouseInputHandler);