如果您使用的是第三方L&F实施,则可能不支持Mac的本机键盘快捷键。
JTextField设置L&F后,以下代码应为还原Mac的键盘快捷键:
InputMap im = (InputMap) UIManager.get("TextField.focusInputMap");im.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.meta_DOWN_MASK), DefaultEditorKit.copyAction);im.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.meta_DOWN_MASK), DefaultEditorKit.pasteAction);im.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.meta_DOWN_MASK), DefaultEditorKit.cutAction);当然,只有在检测到该应用程序正在Mac上运行时,才需要执行此操作,这样才不会影响其他操作系统的键盘映射。



