Java Code Examples for javax.swing.JComponent.requestFocusInWindow()

The following are Jave code examples for showing how to use requestFocusInWindow() of the javax.swing.JComponent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: incubator-netbeans   File: TabbedPane.java   View Source Code Vote up 6 votes
private void switchTab( int tabIndex ) {
    if( !tabAdded[tabIndex] ) {
        tabContent.add( tabs[tabIndex], new GridBagConstraints(tabIndex, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0,0,0,0), 0, 0) ); //NOI18N
        tabAdded[tabIndex] = true;
    }
    if( selTabIndex >= 0 ) {
        buttons[selTabIndex].setSelected(false);
    }
    JComponent compToShow = tabs[tabIndex];
    JComponent compToHide = selTabIndex >= 0 ? tabs[selTabIndex] : null;
    selTabIndex = tabIndex;
    buttons[selTabIndex].setSelected(true);

    if( null != compToHide )
        compToHide.setVisible( false );
    
    compToShow.setVisible( true );
    compToShow.requestFocusInWindow();
}
 
Example 2
Project: rapidminer   File: ListPropertyTable2.java   View Source Code Vote up 6 votes
private boolean startCellEditingAndRequestFocus(int row, int column) {
	if (isCellEditable(row, column)) {
		editCellAt(row, column);
		Component editorComponent = getEditorComponent();
		if (editorComponent != null) {
			if (editorComponent instanceof JComponent) {
				JComponent jComponent = (JComponent) editorComponent;
				if (!jComponent.hasFocus()) {
					jComponent.requestFocusInWindow();
				}
				return true;
			}
		}
	}
	return false;
}
 
Example 3
Project: jiracli   File: CredentialsPanel.java   View Source Code Vote up 6 votes
@Override
public void ancestorAdded(AncestorEvent evt) {
    final JComponent component = evt.getComponent();
    component.requestFocusInWindow();
    // for macOS:
    SwingUtilities.invokeLater(new Runnable() {
        @Override
        public void run() {
            component.requestFocusInWindow();
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    component.requestFocusInWindow();
                }
            });
        }
    });
}
 
Example 4
Project: incubator-netbeans   File: ResultViewPanel.java   View Source Code Vote up 5 votes
@Override
public boolean requestFocusInWindow() {
    if (resultsPanel != null && resultsPanel.getComponentCount() > 0) {
        JComponent comp = (JComponent) resultsPanel.getComponent(0);
        if (comp != null) {
            return comp.requestFocusInWindow();
        }
    }
    return super.requestFocusInWindow();
}
 
Example 5
Project: incubator-netbeans   File: TerminalContainerCommon.java   View Source Code Vote up 5 votes
@Override
   public boolean requestFocusInWindow() {
// redirect focus into terminal
JComponent selected = getSelected();
if (selected != null) {
    return selected.requestFocusInWindow();
} else {
    return super.requestFocusInWindow();
}
   }
 
Example 6
Project: incubator-netbeans   File: TerminalInputOutput.java   View Source Code Vote up 5 votes
@Override
protected void requestFocus() {
    Term term = term();

    if (term != null) {
        JComponent screen = term.getScreen();
        if (screen != null) {
            screen.requestFocusInWindow();
        }
    } else { // avoid random NPE in tests
        setFocusTaken(true);
    }
}
 
Example 7
Project: AgentWorkbench   File: HttpsConfigWindow.java   View Source Code Vote up 5 votes
@Override
public void ancestorAdded(AncestorEvent e) {
	JComponent component = e.getComponent();
	component.requestFocusInWindow();

	if (removeListener)
		component.removeAncestorListener(this);
}
 
Example 8
Project: sbc-qsystem   File: FMedCheckIn.java   View Source Code Vote up 5 votes
private void setFordFocuseEdit(final JComponent e) {
    e.requestFocus();
    e.requestFocusInWindow();
    // фокус для приема данных со сканера штрих-кодов
    java.awt.EventQueue.invokeLater(() -> {
        e.requestFocus();
    });
}