Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE when using UIUtil on linux #14

Open
i-n-g-o opened this issue Mar 6, 2017 · 2 comments
Open

NPE when using UIUtil on linux #14

i-n-g-o opened this issue Mar 6, 2017 · 2 comments

Comments

@i-n-g-o
Copy link

i-n-g-o commented Mar 6, 2017

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
@wikes82
Copy link

wikes82 commented Jul 23, 2017

I'm having this same issue, I found workaround by calling javax.swing.UIManager.getFont("Label.font");
before setting the L&F

@acely
Copy link

acely commented Mar 13, 2018

Have the same issue on linux, @bulenkov maybe it needs fixing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants