I would need help with the following: I am implementing an application in javafx, this application Is called through a click on a button. The problem is that when I close the application then I can not call it again. I have read that you can not call the Application.launch() method more than once. But I found something on the service class. The examples in the documentation page are not very clear. Anyone have an idea of how this could be done? Thank you.
http://docs.oracle.com/javafx/2/threads/jfxpub-threads.htm
my code:
private void jButton1ActionPerformed (java.awt.event.ActionEvent evt) {
WebMap n1 = new WebMap () / / application in javafx
n1.Lunch ();
}
WebMap class: / / javafx application
public void Lunch () {
Application.launch ();
}
You can't launch a JavaFX application more than once in the same process, so don't try to do that.
You need to find an alternative mechanism to do whatever it is you are trying to do.
If you are embedding JavaFX scenes in a Swing application you should be creating new JFXPanels in Swing, not creating new JavaFX Applications on Swing button presses.
If you are intending to have a pure JavaFX application, then there is no need to have a Swing button which launches a JavaFX application, you can just use a JavaFX button instead and directly display the JavaFX scene.
There is no need to use a Service in this case, Service is used for performing repeated background tasks on a another thread, which has nothing to do with what you are attempting.
Read JavaFX for Swing developers if you want to integrate a Swing and JavaFX application.