通过在我的tableview上设置setTableMenuButtonVisible(true),我能够看到一个带有" +"的按钮。在右上角签名,您可以选择显示/隐藏列。我希望使用样式表来更改背景颜色以及标签颜色等,但没有任何作用。我尝试过以下方法:
.button
.toggle-button,
.menu-button {
-fx-background-color: black;
}
答案 0 :(得分:2)
与JavaFX样式一样,我建议使用Oracle文档来查看构成控件的内容(在您的情况下为TableView,并在{{3}中搜索每个元素的默认样式(自JavaFx 8以来的默认样式表)。 知道表格菜单按钮的样式很容易:
/**
* For styling only the "+" button on the right top corner
*/
.table-view > .column-header-background > .show-hide-columns-button {
-fx-background-color: black;
}
/**
* In order to style any other column header's background
*/
.table-view .column-header {
-fx-background-color : yellow;
}
/**
* For styling column header's labels
*/
.table-view .column-header .label {
-fx-text-fill : green;
}