我遇到了一个奇怪的情况,样式为javafx中的组合框按钮。目前,我有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(http://sscce.org)加入 – 2014-08-29 16:38:53
。很明显,你将不得不改变路径到CSS文件。 – thatjavaguy09 2014-08-29 16:48:42