【发布时间】:2014-10-23 17:06:45
【问题描述】:
我遇到了一个奇怪的情况,在 javafx 中设置组合框按钮的样式。目前,我有
.combo-box .arrow {
-fx-background-color: black;
}
.combo-box .arrow-button {
-fx-background-color: white;
-fx-size: 5;
}
将按钮的背景颜色设置为白色,将箭头设置为黑色。如果组合框不可编辑,这很好。但是,如果我有可编辑的组合框,则不会应用此 CSS。
如果组合框是可编辑的,有谁知道我如何设置下拉按钮的样式?
public class SSCCE extends Application{
@Override
public void start(Stage primaryStage) throws Exception {
VBox root = new VBox();
primaryStage.setScene(new Scene(root));
ComboBox editable = new ComboBox();
editable.setEditable(true);
editable.setPrefWidth(125);
ComboBox notEditable = new ComboBox();
notEditable.setEditable(false);
notEditable.setPrefWidth(125);
root.getChildren().addAll(editable, notEditable);
primaryStage.sizeToScene();
primaryStage.show();
StyleManager.getInstance().addUserAgentStylesheet("/theme/styles/ComboBox.css");
}
public static void main(String[] args) {
launch(args);
}
}
【问题讨论】:
-
如需尽快获得更好的帮助,请发帖SSCCE
-
在编辑中添加。显然,您必须更改 CSS 文件的路径。
标签: java css combobox javafx-2 javafx-8