How to style FXML-defined popups?

Werner Lehmann lehmann at
Wed May 30 06:22:19 PDT 2012


I am using FXML to prepare popups and contextmenus in an fx:define block:

>   <fx:define>
>     <Popup fx:id="popup" styleClass="my-popup" .../>
>     <ContextMenu fx:id="contextmenu" styleClass="my-contextmenu" .../>
>   </fx:define>

Unfortunately those popups do not inherit the stylesheets of the scene 
which the fxml is loaded into. Instead, I have to do this after loading 
for each popup and contextmenu:

> contextmenu.getScene().getRoot().getStylesheets().addAll(...);

Is there a simpler way, maybe something I can do directly in FXML... a 
clever binding or somesuch?


More information about the openjfx-dev mailing list