Stage hide/show from Swing

Scott Palmer swpalmer at gmail.com
Mon May 18 12:17:05 UTC 2015


I would have thought that #2 was correct. What happened when you tried it?
Did you make sure JavaFX didn't try to shutdown automatically when the last Stage was hidden?


Scott

> On May 18, 2015, at 7:37 AM, Matthias Hänel <haenel at ultramixer.com> 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
> 
> 
> 


More information about the openjfx-dev mailing list