How to style FXML-defined popups?
lehmann at media-interactive.de
Thu May 31 02:03:48 PDT 2012
the following works as an FXML alternative to adding the stylesheet in
> <String fx:value="/the/fully/qualified/path/to/the/desired.css"/>
It also requires this
> <?import java.lang.String?>
which was a bit unexpected. URL did not work here because it was not
coerced to a string.
However, this does not help with FXML-defined popups and contextmenus
because those do not have a stylesheet property. According to my tests
I'd have to set the property contextmenu.scene.root.stylesheets - not
sure how to do that in FXML and it is a bit long-winded anyway.
On 31.05.2012 03:51, FXML Guide wrote:
> Have tried importing your stylesheet directly into your FXML file?
> <URL value="@thestylesheetname.css" />
>> I am using FXML to prepare popups and contextmenus in an fx:define block:
>>> <Popup fx:id="popup" styleClass="my-popup" .../>
>>> <ContextMenu fx:id="contextmenu" styleClass="my-contextmenu" .../>
>> 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:
>> Is there a simpler way, maybe something I can do directly in FXML... a
>> clever binding or somesuch?
More information about the openjfx-dev