使用Enter键调用按钮的动作是LAF问题。Windows支持该功能,但是在默认的metal LAF中,您使用空格键。
请查看输入键和按钮以获取以下两种解决方案:
您可以使用UIManager在按钮与按钮之间切换时将按钮设置为默认按钮:
UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE);您可以使用键绑定来映射Enter键的按下/释放事件。

使用Enter键调用按钮的动作是LAF问题。Windows支持该功能,但是在默认的metal LAF中,您使用空格键。
请查看输入键和按钮以获取以下两种解决方案:
您可以使用UIManager在按钮与按钮之间切换时将按钮设置为默认按钮:
UIManager.put("Button.defaultButtonFollowsFocus", Boolean.TRUE);您可以使用键绑定来映射Enter键的按下/释放事件。