使用JavaFX中的CSS样式ChoiceBox列表

use*_*882 4 css java javafx

名单

如何在css或代码中访问此列表以进行样式设置.我无法从modena.css中弄明白.

通过使用

.choice-box > * {
    -fx-background-color: black;
}
Run Code Online (Sandbox Code Playgroud)

列表不受影响,因此它是某种单独的控件.

DVa*_*rga 11

以下选择器应在以下菜单中执行着色ChoiceBox:

// Background color of the whole context menu
.choice-box .context-menu { -fx-background-color: black; }
// Focused item background color in the list
.choice-box .menu-item:focused { -fx-background-color: orange; }
// Text color of non-focused items in the list
.choice-box .menu-item > .label { -fx-text-fill: white; }
// Text color of focused item in the list
.choice-box .menu-item:focused > .label { -fx-text-fill: black; }
Run Code Online (Sandbox Code Playgroud)

如果你ChoiceBox进一步着色:

// Background color of the control itself
.choice-box {
  -fx-background-color: black;
  -fx-mark-color: orange; // arrow color
}

// Selected item text color on the control itself
.choice-box > .label { -fx-text-fill: white; }
Run Code Online (Sandbox Code Playgroud)

结果将是ChoiceBox这样的:

在此输入图像描述