Jon Onstott
Jon Onstott

Reputation: 13727

How can I detect that a menu is open in JavaFX?

I'm writing a JavaFX app and have a menubar with partial transparency. When the user mouses over the menubar, it becomes fully opaque. I'd also like it to be opaque when the user has opened one of the menus. Is this possible somehow? I'm using JavaFX 2 if it matters.

Thanks.

Upvotes: 2

Views: 425

Answers (1)

Anshul Parashar
Anshul Parashar

Reputation: 3126

try this..!!

 menu.setOnShowing(new EventHandler<Event>() {

        @Override
        public void handle(Event t)
        menubar.setStyle("-fx-background-color:transparent"); //
       // or you can use set opacity property
       menubar.setOpacity(0.25);
        }
    });

this event occurs when you show you menu...there also menu hidden propety..you can also use it.

Upvotes: 2

Related Questions