[英]JavaFX css menu borders wrong color
I have a JavaFX Application, with a MenuBar, with 3 Menus, with a few MenuItems each.我有一个 JavaFX 应用程序,有一个菜单栏,有 3 个菜单,每个菜单项有几个。
After changing the colors of the MenuBar/Menus/MenuItems, I have these brighter bars (below "Unterstützte Melder" and above "Daten laden")更改 MenuBar/Menus/MenuItems 的颜色后,我有这些更亮的条(在“Unterstützte Melder”下方和“Daten laden”上方)
I would like them to have the same color as the MenuItems Background color, i thought those were borders or shadows, but I did not manage to set them to 0 or remove them.我希望它们具有与 MenuItems 背景颜色相同的颜色,我认为那些是边框或阴影,但我没有设法将它们设置为 0 或删除它们。
I use CSS to style all my components我使用 CSS 来设置所有组件的样式
CSS File: CSS 文件:
.menu-item .label {
-fx-font-size:14.0px;
-fx-text-fill: white;
}
.menu-item:focused {
-fx-background-color: darkgray;
}
.context-menu {
-fx-background-color: #8a8a8a;
}
#override:focused .label {
-fx-text-fill: #ff8800;
}
#override .label {
-fx-text-fill: #ff8800;
}
.menu-bar {
-fx-background-color: #5c5c5c;
}
.button {
-fx-background-color: #CCCCCC;
}
.menu .label {
-fx-text-fill: white;
}
.menu-item {
-fx-background-color: #5c5c5c;
}
.menu {
-fx-background-color: #5c5c5c;
}
.menu:hover {
-fx-background-color: darkgray;
}
If you have 1 context-menu
on the scene at the same time:如果您同时在场景中有 1 个context-menu
:
I succeeded to change the backgroung color of Menu
node to red by adding this code to the style sheet:通过将此代码添加到样式表中,我成功地将Menu
节点的背景颜色更改为红色:
.context-menu {
-fx-background-color: #ff0000;
-fx-border-color: #ff0000;
}
I suppose you are attaching your style sheet to the .fxml
file, if no, you can do it by specifying the path in SceneBuilder:我想您正在将样式表附加到.fxml
文件,如果没有,您可以通过在 SceneBuilder 中指定路径来完成:
If you have 2 context-menu
on the scene at the same time:如果您同时在场景中有 2 个context-menu
:
Just specify 2 style sheets and then attach them sepparately for different MenuBar
nodes like on screenshot above.只需指定2 个样式表,然后将它们分别附加到不同的MenuBar
节点,如上面的屏幕截图所示。 In each style sheet specify .context-menu
class with desired properties.在每个样式表中指定具有所需属性.context-menu
类。 This way it won't override each other.这样它就不会互相覆盖。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.