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

Some controls can only be created on the FX application thread

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: fx2.0
    • Fix Version/s: 8u40
    • Component/s: javafx
    • Environment:

      WinXPSP3, JavaFX2.0GA, JDK7u2b8

      Description

      http://download.oracle.com/javafx/2.0/api/javafx/application/Application.html#init%28%29 states:
        "NOTE: This method is not called on the JavaFX Application Thread. An application must not construct a Scene or a Stage in this method. An application may construct other JavaFX objects in this method."

      However, some JavaFX controls can only be constructed on the JavaFX Application Thread.

      Perhaps this is as designed, and only clarification of documentation as specified in RT-16918 is required.

      Sample test case:

      import javafx.application.Application;
      import javafx.scene.control.*;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;

      public class InitThreadTest extends Application {
          public static void main(String[] args) { Application.launch(args); }
          @Override public void init() throws Exception {
              new Button();
              try { new WebView(); } catch (Exception e) { e.printStackTrace(); }
              try { new Tooltip(); } catch (Exception e) { e.printStackTrace(); }
              try { new ContextMenu(); } catch (Exception e) { e.printStackTrace(); }
          }
          @Override public void start(Stage s) { System.exit(0); }
      }

      Output of code is =>

      java.lang.IllegalStateException: Not on FX application thread; currentThread = JavaFX-Launcher
      at com.sun.javafx.tk.Toolkit.checkFxUserThread(Unknown Source)
      at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(Unknown Source)
      at com.sun.webpane.sg.prism.InvokerImpl.checkEventThread(Unknown Source)
      at com.sun.webpane.platform.WebPage.<init>(Unknown Source)
      at com.sun.webpane.sg.ImplementationManager.createPage(Unknown Source)
      at com.sun.webpane.sg.ImplementationManager.createPage(Unknown Source)
      at javafx.scene.web.WebEngine.<init>(Unknown Source)
      at javafx.scene.web.WebEngine.<init>(Unknown Source)
      at javafx.scene.web.WebView.<init>(Unknown Source)
      at InitThreadTest.init(InitThreadTest.java:10)
      at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
      at com.sun.javafx.application.LauncherImpl.access$000(Unknown Source)
      at com.sun.javafx.application.LauncherImpl$1.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:722)
      java.lang.IllegalStateException: Not on FX application thread; currentThread = JavaFX-Launcher
      at com.sun.javafx.tk.Toolkit.checkFxUserThread(Unknown Source)
      at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(Unknown Source)
      at javafx.scene.Scene.<init>(Unknown Source)
      at javafx.scene.Scene.<init>(Unknown Source)
      at javafx.stage.PopupWindow.<init>(Unknown Source)
      at javafx.scene.control.PopupControl.<init>(Unknown Source)
      at javafx.scene.control.Tooltip.<init>(Unknown Source)
      at InitThreadTest.init(InitThreadTest.java:11)
      at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
      at com.sun.javafx.application.LauncherImpl.access$000(Unknown Source)
      at com.sun.javafx.application.LauncherImpl$1.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:722)
      java.lang.IllegalStateException: Not on FX application thread; currentThread = JavaFX-Launcher
      at com.sun.javafx.tk.Toolkit.checkFxUserThread(Unknown Source)
      at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(Unknown Source)
      at javafx.scene.Scene.<init>(Unknown Source)
      at javafx.scene.Scene.<init>(Unknown Source)
      at javafx.stage.PopupWindow.<init>(Unknown Source)
      at javafx.scene.control.PopupControl.<init>(Unknown Source)
      at javafx.scene.control.ContextMenu.<init>(Unknown Source)
      at InitThreadTest.init(InitThreadTest.java:12)
      at com.sun.javafx.application.LauncherImpl.launchApplication1(Unknown Source)
      at com.sun.javafx.application.LauncherImpl.access$000(Unknown Source)
      at com.sun.javafx.application.LauncherImpl$1.run(Unknown Source)
      at java.lang.Thread.run(Thread.java:722)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                msladecek Martin Sládeček
                Reporter:
                josmithjfx John Smith (Inactive)
              • Votes:
                10 Vote for this issue
                Watchers:
                26 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: