如何设置输入键到下一个焦点而不是jbutton

时间:2013-10-20 12:33:00

标签: java swing jbutton

我有问题。我将enter键设置为下一个焦点并触发jbutton,但是触发jbutton不起作用。

Set<AWTKeyStroke> set = new HashSet<AWTKeyStroke>(KeyboardFocusManager
    .getCurrentKeyboardFocusManager().getDefaultFocusTraversalKeys(
        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS));

set.add(KeyStroke.getKeyStroke("ENTER"));
    KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalKeys(
        KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, set);
    UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE);

0 个答案:

没有答案