January 4, 201610 yr Edit: Nevermind, got the error now: Caused by: java.lang.IllegalStateException: This operation is permitted on the event thread only; currentThread = pool-1-thread-2 I am having issues with launching a JavaFX application from the onStart method in Script. There is no issue with the application itself, as it works perfectly fine when called from the main method in the same class. I am launching the application using the following code, it produces "error in script onStart()", but no useful message: @Override public void onStart(){ ClassName.launch(ClassName.class); } Thanks Edited January 4, 201610 yr by Explv
January 4, 201610 yr You need to encapsulate it within a JFrame. public class YourGui extends JFXPanel { ... public static JFrame create() { JFrame frame = new JFrame(); YourGui gui = new YourGui (); Platform.runLater(() -> { gui.init(); frame.setContentPane(gui); }); } public void init() { final BorderPane container = new BorderPane(); container.setTop(someComponent); container.setCenter(someOtherComponent); final Scene scene = new Scene(container); setScene(scene); } ... } Edit: You might only need to wrap the GuiClass.launch in a Platform.runLater Edited January 4, 201610 yr by Valkyr
January 4, 201610 yr Author Edit: You might only need to wrap the GuiClass.launch in a Platform.runLater Just tried: Platform.runLater(() -> ClassName.launch(ClassName.class)); But no dice, I will try your full solution now, thanks man
January 4, 201610 yr You need to encapsulate it within a JFrame. public class YourGui extends JFXPanel { ... public static JFrame create() { JFrame frame = new JFrame(); YourGui gui = new YourGui (); Platform.runLater(() -> { gui.init(); frame.setContentPane(gui); }); } public void init() { final BorderPane container = new BorderPane(); container.setTop(someComponent); container.setCenter(someOtherComponent); final Scene scene = new Scene(container); setScene(scene); } ... } Edit: You might only need to wrap the GuiClass.launch in a Platform.runLater Lool Valk he doesnt know the head ache hes getting himself into.
January 4, 201610 yr Author You need to encapsulate it within a JFrame. Got it to work by doing this. Thanks dude
Create an account or sign in to comment