Java Swing KeyStroke registerTabKey(Container container)

Here you can find the source of registerTabKey(Container container)

Description

register Tab Key

License

Open Source License

Declaration

public static void registerTabKey(Container container)
        

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.awt.Component;

import java.awt.Container;
import java.awt.DefaultKeyboardFocusManager;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;

import javax.swing.JComponent;

import javax.swing.KeyStroke;

public class Main {
    public static void registerTabKey(Container container)
    /*      */{/*from   ww w .j a  va2s.  co m*/
        /* 2074 */if ((container instanceof JComponent)) {
            /* 2075 */((JComponent) container).registerKeyboardAction(
                    new AbstractAction()
                    /*      */{
                        /*      */public void actionPerformed(ActionEvent e)
                        /*      */{
                            /* 2079 */DefaultKeyboardFocusManager
                                    .getCurrentKeyboardFocusManager()
                                    .focusNextComponent();
                            /*      */}
                        /*      */
                    }
                    /*      */, KeyStroke.getKeyStroke(9, 0), 0);
            /*      */}
        /*      */else
        /*      */{
            /* 2084 */for (int i = 0; i < container.getComponentCount(); i++) {
                /* 2085 */Component c = container.getComponent(i);
                /*      */
                /* 2088 */if (((c instanceof JComponent))
                        && (c.isFocusable()))
                    /* 2089 */((JComponent) container)
                            .registerKeyboardAction(new AbstractAction()
                            /*      */{
                                /*      */public void actionPerformed(
                                        ActionEvent e)
                                /*      */{
                                    /* 2093 */DefaultKeyboardFocusManager
                                            .getCurrentKeyboardFocusManager()
                                            .focusNextComponent();
                                    /*      */}
                                /*      */
                            }
                            /*      */, KeyStroke.getKeyStroke(9, 0), 0);
                /*      */}
            /*      */}
        /*      */}
}

Related

  1. registerAsAction(final KeyStroke keyStroke, final String actionKey, final Runnable action, final JComponent component)
  2. registerKeyBinding(final JComponent aComponent, final String aKeyStroke, final Action aAction)
  3. registerKeyBoardAction(JComponent comp, Action action, KeyStroke stroke)
  4. registerKeyHandler(JComponent component, KeyStroke stroke, final ActionListener listener, final String actionCommand)
  5. registerKeystroke(final JComponent aComponent, final Action aAction, final String aCommandName)
  6. removeAcceleratorFromChildren(Container container, KeyStroke accelerator)
  7. removeAcceleratorFromComponent(JComponent component, KeyStroke accelerator)
  8. removeAcceleratorFromMap(InputMap map, KeyStroke accelerator)
  9. removeButtonClickKeystroke(AbstractButton b, KeyStroke key)