0
我试图改变Look&Feel
Java Swing:无法从应用程序包创建资源。使用基于Java的资源
public class Main {
public static void main(String[] args) {
try {
String osName = System.getProperty("os.name");
if (osName.contains("Mac")) {
System.setProperty("apple.laf.useScreenMenuBar", "true");
}
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e1) {
}
}
}
但得到线UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
java.lang.NullPointerException
Failed to create resources from application bundle. Using Java-based resources.
at java.io.File.<init>(File.java:222)
at com.apple.resources.LoadNativeBundleAction.run(MacOSXResourceBundle.java:60)
at com.apple.resources.LoadNativeBundleAction.run(MacOSXResourceBundle.java:33)
at java.security.AccessController.doPrivileged(Native Method)
at com.apple.resources.MacOSXResourceBundle.getMacResourceBundle(MacOSXResourceBundle.java:29)
at com.apple.resources.MacOSXResourceBundle.getMacResourceBundle(MacOSXResourceBundle.java:24)
at com.apple.laf.AquaLookAndFeel.initResourceBundle(AquaLookAndFeel.java:244)
at com.apple.laf.AquaLookAndFeel.initComponentDefaults(AquaLookAndFeel.java:260)
at com.apple.laf.AquaLookAndFeel.getDefaults(AquaLookAndFeel.java:227)
at javax.swing.UIManager.setLookAndFeel(UIManager.java:520)
at javax.swing.UIManager.setLookAndFeel(UIManager.java:564)
at org.camobap.osx.Main.main(Main.java:26)
例外谁能HEPL我避免这个问题?
更新: jdk1.7.0_09
[按照苹果(http://developer.apple.com/library/mac/#documentation/Java/参考/ Java_PropertiesRef/Articles/JavaSystemProperties.html):*当在你的应用程序中设置一个属性时(使用System.setProperty),确保它是你的main方法中的第一个语句之一。这样做会在AWT加载之前设置属性,以确保其生效。*也许尝试在不检查操作系统的情况下设置该属性并查看它是否可用 –
哪种语言在Mac上的语言和文本系统首选项的顶部位置?这似乎是你有一些问题与MAC资源包 –
运行良好在我的Mac与JDK1.7 – Robin