List of utility methods to do Swing Focus
void | setNextFocusable(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(); }); |
Component | smartRequestFocus(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; ... |