Himanshu Gogoi
Himanshu Gogoi

Reputation: 21

Running javafx application thread more than once

I am working on an java application where I'm using java swing forms and javafx FXML stage.I am new to javafx.Now in my app I'm calling javafx fxml stage having controller,from a swing form.I'm calling the fxml stage from the swing form on clicking a button like this---- Application.launch(MyFxml.class);

This works fine.But when I go back again from the fxml stage to the swing form by clicking a button in the following way and try to access the javafx fxml stage I'm getting exceptions. new MySwingform().setVisible(true);

The following code snippet is used to call up the swing form---

    public void goBack(ActionEvent ev){

    Platform.exit();

    new MySwingform().setVisible(true);
}

The exception I'm getting is "Application launch must not be called more than once".So,how to get rid of this so that we can run the javafx application thread over and over again without any error?Thanks in advance for your useful suggestions.

Upvotes: 0

Views: 1371

Answers (1)

assylias
assylias

Reputation: 328873

To show JavaFX components within a swing application, you should place them on JFxPanel instead of launching a new fx application.

To do the opposite (embed swing components within a Java FX application), you need Java FX 8's SwingNode.

Upvotes: 4

Related Questions