iconloader
iconloader copied to clipboard
NPE when using UIUtil on linux
hi.
when initializing on linux (this is on ubuntu in a VM with oracle java 1.8.0_121) initSystemFontData()
in UIUtil.java line 254 throws a NPE because font
is null.
getLabelFont()
returns null.
(UIUtil.initSystemFontData()
gets called because the System property "hidpi" is not set. looking into JBUI.java:47
it sets the scaleFactor = 1.0f;
if hidpi != null
and not "true")
a workaround is to set hidpi=false and avoid the call to initSystemFontData()
alltogether.
the real question is: why does getLabelFont() return null?
using this test application:
import javax.swing.*;
public class Darculatest
{
public static void main(String[] args) {
System.out.println("setting look and feel");
try {
UIManager.setLookAndFeel("com.bulenkov.darcula.DarculaLaf");
} catch (Exception e) {
e.printStackTrace();
}
}
}
throws this exceptions:
setting look and feel
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 Darculatest.main(Darculatest.java:11)
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)
... 5 more
I'm having this same issue, I found workaround by calling javax.swing.UIManager.getFont("Label.font"); before setting the L&F
Have the same issue on linux, @bulenkov maybe it needs fixing.