实现按ENTER,TAB可以按程序输入的控件顺序顺序移动

        Set forwardKeySet  =   new  HashSet();
        forwardKeySet.add(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 
0 ));//注册ENTER
        KeyboardFocusManager.getCurrentKeyboardFocusManager()
                .setDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardKeySet);

        forwardKeySet.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 
0 ));//注册TAB
        KeyboardFocusManager.getCurrentKeyboardFocusManager()
                .setDefaultFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardKeySet);

上面两个小程序可实现按ENTER,TAB可以按程序输入的控件顺序顺序移动。 

你可能感兴趣的:(tab)