JDK-8119292 : QuantumToolKit isSupported throws NullPointerException if Application.setUserAgentStylesheet called before Application.launch
  • Type: Bug
  • Component: javafx
  • Sub-Component: application-lifecycle
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • Submitted: 2013-03-13
  • Updated: 2015-06-17
  • Resolved: 2013-09-30
Related Reports
Blocks :  
Description
public class Main extends Application {

    public static void main(String[] args) {
        Application.setUserAgentStylesheet(STYLESHEET_MODENA);
        Application.launch(Main.class, args);
    }
...

If you move the call to setUserAgentStylesheet to the start(Stage) method, everything is fine.

Using Modena Theme
Exception in thread "main" java.lang.NullPointerException
	at com.sun.javafx.tk.quantum.QuantumToolkit.isSupported(QuantumToolkit.java:1208)
	at com.sun.javafx.application.PlatformImpl.isSupported(PlatformImpl.java:447)
	at com.sun.javafx.application.PlatformImpl$11.run(PlatformImpl.java:543)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sun.javafx.application.PlatformImpl.setPlatformUserAgentStylesheet(PlatformImpl.java:539)
	at javafx.application.Application.setUserAgentStylesheet(Application.java:434)
	at fxtest.Main.main(Main.java:40)

Comments
Verified that this is no longer an issue.
30-09-2013

And since we don't officially support JDK 7 with FX 8, I will likely resolve this as "Not an issue". I will make sure to test it when fixing RT-28755.
13-03-2013

Note that this will not be an issue if using JDK 8 -- at least not once RT-28755 is implemented (currently main() is not even called for FX apps in JDK 8).
13-03-2013