Reputation: 645
How does one change the color of a JavaFX 2 MenuBar
in JavaFX Scene Builder? I want to make it the same color as the menu bar in the Scene Builder. CSS´s color
and background-color
doesn't seem to help.
I'd also be happy to know the color of the Scene Builder menu bar (in hexadecimal or decimal RGB).
Upvotes: 2
Views: 6266
Reputation: 1248
You can use the fx-background-color
css property to set the menu bar background color.
Regarding the Scene Builder menu bar background color, you can use:
-fx-background-color:
derive(#e0e0e0, -0.291),
linear-gradient(
to bottom,
derive(#e0e0e0, 0.353) 0%,
derive(#e0e0e0, -0.058) 100%
);
-fx-background-insets: 0, 0 0 1 0;
I extracted these css "coordinates" from Scene Builder jar, located at SceneBuilderInstalationRoot/lib/SceneBuilder.jar
. In the jar, its on the package com.oracle.javafx.authoring.css_stylesheets
, file SceneBuilderTheme.css. This css file uses a named constant -fx-color
which I inferred to have value #e0e0e0
.
Upvotes: 3
Reputation: 5032
You can find help about css directly in scene builder : on the menu View > Show CSS analyser
here you will can see that the menu bar use the class .menu-bar
and have this -fx-background-color
set with some color. So now you know that you have to put on the style of your MenuBar
-fx-background-color : thecoloryouwant
And that it.
Upvotes: 3