package test.swing; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import javafx.application.Platform; import javafx.embed.swing.JFXPanel; import javafx.scene.control.Button; public class FXInitTest { public static void main(String[] args) throws InterruptedException { final AtomicBoolean flag = new AtomicBoolean(false); List threads = new ArrayList(); for (int i = 0; i < 5; i++) threads.add( new Thread("runLater") { public void run() { while (!flag.get()); // stall this until all threads are at this point new JFXPanel(); // should init the toolkit in JFXPanel.initFX Platform.runLater(new Runnable() { // throws IllegalStateException, eventually public void run() { new Button(); } }); }; }); for (Thread t : threads) t.start(); Thread.sleep(500); // make sure all threads are running and waiting for the flag flag.set(true); for (Thread t : threads) t.join(); System.exit(0); } }