I tried to change styles in menu button. I could change menu button style but not its menu item. No matter what i try menu item inside menu-button remains unchanged.
.menu-button {
-fx-background-color:black;
}
.menu-button .label {
-fx-background-color:black; }
Now how can i change color that is left out??
This has also been asked here and here, so I decided to write a CSS template for styling menu bars.
Using this CSS template is a very easy way to style a
MenuBar
, its top-levelMenuButton
entries, and eachMenuButton
'sMenuItem
children, i.e, "the whole menu bar".The only thing that has to be done is to adjust four variables according to one's needs:
-fx-my-menu-color
: The menu bar's default background color (i.e., when item is not hovered / selected)-fx-my-menu-color-highlighted
: An item's background color if it is hovered / selected.-fx-my-menu-font-color
: The menu bar's default font color (i.e., when item is not hovered / selected)-fx-my-menu-font-color-highlighted
: An item's font color if it is hovered / selected.The complete CSS file is commented to explain each defined rule:
MenuButton
usesMenu
internally and has a similar API. In such way thatMenuButton
containsMenuItem
s list just likeMenu
. So I think you need to try to play with.menu
,.menu-button
and.menu-item
CSS selectors in caspian.css. More specifically with.menu-item
.EDIT: It seems you need to change the
.context-menu
too, because the popped up menu of the menuButton is ContextMenu.