有没有办法在OS X上使用Nimbus LAF(外观和感觉),同时仍然能够使用Meta键进行剪切/复制/粘贴和全选操作?
我目前在我的Swing应用程序的主方法中使用以下代码,根据操作系统更改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在Mac OS X上覆盖了剪切/复制/粘贴和全选的键盘快捷方式(Meta键与Ctrl键)。 我希望一直使用Nimbus,只要键盘快捷方式没有被覆盖掉就可以了。