Java Utililty Methods Swing Focus

List of utility methods to do Swing Focus

Description

The list of methods to do Swing Focus are organized into topic(s).

Method

voidsetNextFocusable(JComponent component, final JComponent nextFocusable)
set Next Focusable
component.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "setNextFocusable");
component.getActionMap().put("setNextFocusable", new AbstractAction() {
    public void actionPerformed(ActionEvent e) {
        nextFocusable.requestFocusInWindow();
});
ComponentsmartRequestFocus(Component component)
Requests focus for a component.
if (requestFocus(component))
    return component;
if (component instanceof JComponent) {
    FocusTraversalPolicy policy = ((JComponent) component).getFocusTraversalPolicy();
    if (policy != null) {
        Component focusComponent = policy.getDefaultComponent((Container) component);
        if (focusComponent != null && requestFocus(focusComponent)) {
            return focusComponent;
...