Java Code Examples for org.openide.windows.TopComponent#requestFocusInWindow()
The following examples show how to use
org.openide.windows.TopComponent#requestFocusInWindow() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractModeContainer.java From netbeans with Apache License 2.0 | 6 votes |
@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(); } } }
Example 2
Source File: CloseWindowAction.java From netbeans with Apache License 2.0 | 6 votes |
/** Perform the action. Sets/unsets maximzed mode. */ public void actionPerformed(java.awt.event.ActionEvent ev) { TopComponent topC = tc; if (topC == null) { // the updating instance will get the TC to close from winsys topC = TopComponent.getRegistry().getActivated(); } if(topC != null) { //132852 - if the close action is canceled then the input focus may be lost //so let's make sure the window get input focus first topC.requestFocusInWindow(); final TopComponent toClose = topC; SwingUtilities.invokeLater( new Runnable() { public void run() { ActionUtils.closeWindow(toClose); } }); } }
Example 3
Source File: SplitAction.java From netbeans with Apache License 2.0 | 5 votes |
static void splitWindow(TopComponent tc, int orientation, int splitLocation) { if (tc instanceof Splitable) { TopComponent split = ((Splitable) tc).splitComponent(orientation, splitLocation); split.open(); split.requestActive(); split.invalidate(); split.revalidate(); split.repaint(); split.requestFocusInWindow(); } }
Example 4
Source File: SplitAction.java From netbeans with Apache License 2.0 | 5 votes |
static void clearSplit(TopComponent tc, int elementToActivate) { if (tc instanceof Splitable) { TopComponent original = ((Splitable) tc).clearSplit(elementToActivate); original.open(); original.requestActive(); original.invalidate(); original.revalidate(); original.repaint(); original.requestFocusInWindow(); } }
Example 5
Source File: TabContainer.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void stateChanged( ChangeEvent e ) { TopComponent tc = tabbedImpl.getSelectedTopComponent(); if( tc != null ) { boolean wasVisible = tc.isVisible(); layout.showComponent( tc, tcPanel ); if( !wasVisible ) tc.requestFocusInWindow(); } }