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

Embed JavaFx into a swing app does not work (wrong thread)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: fx2.0
    • Fix Version/s: None
    • Component/s: javafx
    • Environment:

      Windows Vista

      Description

      Application:

      public class SwingFx extends JFrame
      {
      public static void main(String[] pArgs)
      {
      SwingUtilities.invokeLater(new Runnable()
      {
      public void run()
      {
      new SwingFx();
      }
      });
      }

      public SwingFx()
      {
              TableView tview = new TableView();
              
              BorderPane bpane = new BorderPane();
              bpane.setCenter(tview);
              
              Scene scene = new Scene(bpane);
              
      setPreferredSize(new Dimension(640, 480));
      setLayout(new BorderLayout());

      JFXPanel jvxpan = new JFXPanel();
      jvxpan.setScene(scene);

      add(new JButton("PRESS"), BorderLayout.WEST);
      add(jvxpan, BorderLayout.CENTER);

      pack();
      setVisible(true);
      }

      }


      Exception in thread "AWT-EventQueue-0" java.lang.IllegalStateException: Not on FX user thread; currentThread = AWT-EventQueue-0
      at com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:218)
      at javafx.scene.Scene.<init>(Scene.java:142)
      at javafx.scene.Scene.<init>(Scene.java:122)
      at com.sibvisions.javafx.SwingFx.<init>(SwingFx.java:89)
      at com.sibvisions.javafx.SwingFx$1.run(SwingFx.java:30)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

        Attachments

          Activity

            People

            • Assignee:
              art Artem Ananiev
              Reporter:
              rjahnjfx René Jahn (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: