How to style FXML-defined popups?

David Grieve david.grieve at
Wed May 30 06:59:16 PDT 2012

This looks like a bug to me. The popup should get the styles from the stylesheets of the scene of the popup's owner window.  

On May 30, 2012, at 9:22 AM, Werner Lehmann wrote:

> Hi,
> 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?
> Rgds
> Werner

David Grieve | Principal Member of Technical Staff
Mobile: +16033121013 
Oracle Java Client UI and Tools
Durham, NH 03824 
 Oracle is committed to developing practices and products that help protect the environment

More information about the openjfx-dev mailing list