Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8090933

Method for checking if JavaFX is running

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 7u25
    • javafx
    • None

      If you invoke Platform.runLater you may get the exception below, if JavaFX is not initialized. Consequently, I suggest adding a method to Platform called isInitialized which would allow me to check if JavaFX is initialized before the invocation.

      This is especially relevant in third party frameworkds like mine which may and may not be used with JavaFX. I have code that, when used with JavaFX, should invoke Platform.runLater but when used in a non-JavaFX app should just run immediately.

      An alternative solution to this could be to change Platform.runLater to be able to operate even when JavaFX is not running in which case it could just delegate the work to a different thread than the JavaFX app thread. This would mean that the IllegalStateException would never be thrown.


      java.lang.IllegalStateException: Toolkit not initialized
      at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:155)
      at com.sun.javafx.application.PlatformImpl.runLater(PlatformImpl.java:150)
      at javafx.application.Platform.runLater(Platform.java:52)
      at com.wefend.services.grid.defence.DefenceGridDelegate.setLocalSitrep(DefenceGridDelegate.java:125)
      at com.wefend.services.grid.defence.DefenceGridDelegate.update(DefenceGridDelegate.java:121)
      at com.wefend.defender.DefenderBean.update(DefenderBean.java:141)
      at com.wefend.services.grid.AppBean$1.run(AppBean.java:103)
      at java.lang.Thread.run(Thread.java:724)

            Unassigned Unassigned
            risaksen Randahl Isaksen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Imported: