Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to call Stage’s show/hide methods from AWT-thread

SteamusNov 17 2011 — edited May 25 2012
Hello Everybody,

I would like to use java SystemTray functionality with JavaFX application. So, I implemented TrayIcon with MouseListener. My FX-Application started but primary stage is not visible. Then I want to show/hide my FX-Stage by clicking mouse on TrayIcon.

Because I can call stage.show()/hide() from FX thread only I use Platform.runLater( fxTread ). Something like this:
Platform.runLater( new Runnable()
{
    public void run()
    {
        if( stage.isShowing() )
        {
            stage.hide();
        }
        else
        {
            stage.show();
        }
    }
 } );
It works, but one time only. Just show and hide. Looks like the Platform.runLater( thread ) doesn’t finish FX- thread and it is unavailable any more to manipulate the visibility of stage.

Is there a way how to do it?

Thank you.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 22 2012
Added on Nov 17 2011
14 comments
17,657 views