You should call Platform.setImplicitExit(false) to disable the default
behavior where the FX toolkit exits when the last Stage is closed.
One more suggestion:
PlatformImpl.startup(new Runnable()
This is not public API and should be avoided. If you are running a Swing
application and want to startup the FX toolkit, you should create a new
instance of JFXPanel (even if you don't use it).
-- Kevin
Matthias Hänel wrote:
Hello there,
I have a stage that is been called from a Java Swing application. This is not a
real problem
since I can run follwing code:
PlatformImpl.startup(new Runnable()
{
@Override
public void run()
{
myStage = new myStage();
myStage.show();
}
});
That works so far.
No I would like to close this stage from the swing application. I can call:
Platform.runLater(new Runnable()
{
@Override
public void run()
{
myStage.hide();
}
});
This also works.
Since I have a toggle-Button to hide and show the stage from the swing
application, I would like
to re-show the stage and I would like to know when the stage is showing or not.
This seems to be nearly impossible by now.
What did I try?
1. I tried to shutdown the javafx entire with
com.sun.javafx.tk.Toolkit.getToolkit().exit(); in the hide process. So I
expected to use PlatformImpl.startup again. Unfortunately, it did not work.
2. I tried to leave javafx untouched. The second time I only call
PlatformImpl.runLater to create a new scene.
3. I tried to run it from the swing thread without Platform.run... ... this failed obviuosly. (I just had no further ideas ;))
Does anyone tried this before? Any advise will be helpful :)
Thanks in advance
Matthias