bulenkov / Darcula

Darcula Look and Feel
Apache License 2.0
723 stars 114 forks source link

Linux: NullPointerException in iconloader library #29

Open AlexFalappa opened 7 years ago

AlexFalappa commented 7 years ago

When trying to run the SwingSet2 demo on Ubuntu Linux with Oracle JDK I get the following exception:

Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.bulenkov.iconloader.IconLoader.<clinit>(IconLoader.java:53)
    at com.bulenkov.darcula.DarculaLaf.getDefaults(DarculaLaf.java:97)
    at javax.swing.UIManager.setLookAndFeel(UIManager.java:539)
    at javax.swing.UIManager.setLookAndFeel(UIManager.java:583)
    at javax.swing.UIManager.initializeDefaultLAF(UIManager.java:1349)
    at javax.swing.UIManager.initialize(UIManager.java:1459)
    at javax.swing.UIManager.maybeInitialize(UIManager.java:1426)
    at javax.swing.UIManager.getUI(UIManager.java:1006)
    at javax.swing.JPanel.updateUI(JPanel.java:126)
    at javax.swing.JPanel.<init>(JPanel.java:86)
    at javax.swing.JPanel.<init>(JPanel.java:109)
    at javax.swing.JPanel.<init>(JPanel.java:117)
    at SwingSet2.<init>(SwingSet2.java:182)
    at SwingSet2.main(SwingSet2.java:245)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: java.lang.NullPointerException
    at com.bulenkov.iconloader.util.UIUtil.initSystemFontData(UIUtil.java:254)
    at com.bulenkov.iconloader.util.JBUI.calculateScaleFactor(JBUI.java:47)
    at com.bulenkov.iconloader.util.JBUI.<clinit>(JBUI.java:33)
    ... 19 more

JDK:

java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
lukbukkit commented 7 years ago

I had this issue too and found out that if you call UIManager.getFont("Label.font"); before you set the Look and Feel it works. Maybe the font is incorrect, but it works. However this is just a quick workaround.

AlexFalappa commented 7 years ago

Verified the issue is Linux specific, it does not happen on the same machine under Windows 10 and Oracle JDK 8.

Edited title accordingly