Here you can find the source of registerTabKey(Container container)
Parameter | Description |
---|---|
container | a parameter |
public static void registerTabKey(Container container)
//package com.java2s; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Main { /**/*from w w w .j a v a2 s . c o m*/ * Register the tab key with the container. * * @param container */ public static void registerTabKey(Container container) { if (container instanceof JComponent) { ((JComponent) container).registerKeyboardAction( new AbstractAction() { public void actionPerformed(ActionEvent e) { // JDK 1.3 Porting Hint // comment out for now DefaultKeyboardFocusManager .getCurrentKeyboardFocusManager() .focusNextComponent(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), JComponent.WHEN_FOCUSED); } else { for (int i = 0; i < container.getComponentCount(); i++) { Component c = container.getComponent(i); // JDK 1.3 Porting Hint // change to isFocusTraversable() if (c instanceof JComponent && c.isFocusable()) { ((JComponent) container).registerKeyboardAction( new AbstractAction() { public void actionPerformed(ActionEvent e) { // JDK 1.3 Porting Hint // comment out for now DefaultKeyboardFocusManager .getCurrentKeyboardFocusManager() .focusNextComponent(); } }, KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), JComponent.WHEN_FOCUSED); } } } } }