ContextMenu styling (esp. for MenuButton)

Werner Lehmann lehmann at media-interactive.de
Tue Oct 23 09:12:50 PDT 2012


Hi,

I want to show a button with a custom node dropdown. Seems like a good 
job for a MenuButton with a single CustomMenuItem. This works ok but 
styling is difficult - how can I style the menuitem/contextmenu used by 
the MenuButton skin? Apparently I cannot access it from the MenuButton 
control.

Basically I just want to remove the blue hover and reduce the borders to 
get something like a "PopupButton". According to the Javadoc it was 
possible at some point to use the custom node directly in 
MenuButton.items. This is obviously not the case anymore because items 
is generically typed to MenuItem elements (RT-25770). Too bad for me, 
this is probably just what I need here.

On a more general note, is this the correct and simplest way to style a 
ContextMenu (once I have a reference to it)?

contextmenu
   .getScene()
   .getRoot()
   .getStylesheets()
   .addAll(...stylesheet...)

It would be nice if the contextmenu could inherit the stylesheet of the 
scene it is used on - or in the case of controls like MenuButton, 
inherit the stylesheet of the control's scene. Any thoughts about that?

Rgds
Werner


More information about the openjfx-dev mailing list