【发布时间】:2012-03-20 00:50:13
【问题描述】:
有没有办法在 OS X 上使用 Nimbus LAF(外观和感觉),同时仍然能够使用 Meta 键进行剪切/复制/粘贴和全选操作?
我目前在我的 Swing 应用程序的 main 方法中有以下代码,它根据操作系统更改 LAF(OS X 的默认值,所有其他的 Nimbus):
if (!System.getProperty("os.name", "").startsWith("Mac OS X")) {
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(LicenseInspectorUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(LicenseInspectorUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(LicenseInspectorUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(LicenseInspectorUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
}
我这样做是一种解决方法,因为 Nimbus 覆盖了 OS X 上用于剪切/复制/粘贴和全选的键盘快捷键(Meta 键与 Ctrl 键)。如果不覆盖键盘快捷键,我更愿意一直使用 Nimbus。
【问题讨论】:
标签: java macos swing keyboard-shortcuts nimbus