Javafx TableView tabelmenubutton CSS 样式表

Javafx TableView tabelmenubutton CSS Stylesheet

通过在我的表格视图上设置 setTableMenuButtonVisible(true),我可以在右上角看到一个带有“+”符号的按钮,您可以在其中 select 到 show/hide 列。我希望使用样式表来更改背景颜色以及标签颜色等,但没有任何效果。我试过以下方法:

.button
.toggle-button,
.menu-button {
   -fx-background-color: black;
}

与往常一样,当它涉及 JavaFX 样式时,我建议使用 Oracle 文档以查看控件的构成(在您的情况下 TableView and to search the default styling for each element in Modena.css(自 JavaFx 以来的默认样式 sheet 8). 知道设置 table 菜单按钮的样式很容易:

/**
 * 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;
}