我遇到了一個奇怪的情況,樣式爲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