這是我的CSS:
.combo-box {
-fx-background-color: transparent;
-fx-border-color: #44494F[/span]。
-fx-邊框寬度: 1px
}
.combo-box .arrow {
-fx-background-color: white;
-fx-shape: -arrow;
}
.combo-box:showing .arrow {
-fx-rotate: 180;
}
.combo-box .list-cell {
-fx-font-size: 10px;
-fx-text-fill: white;
}
.combo-box-popup .list-view {
-fx-background-color: #2F353D;
}
.combo-box-popup .list-view .list-cell {
-fx-background-color: #2F353D;
-fx-邊框寬度: 0px
}
.combo-box-opup .list-view .list-cell:fill:selected, .combo-box-opup .list-view .list-cell:fill:selected:hover{
-fx-font-weight: bold;
-fx-形狀。 "m184.405 461.013-184.405-184.405 24.354-24.354 160.051 160.051 332.279-332.279 24.354z"。
}
.combo-box-popup .list-view .list-cell:fill:hover{
-fx-background-color: #393E44;
}
是否有辦法只用CSS就能把勾放在右邊?即使沒有,如何實作呢?
uj5u.com熱心網友回復:
正如@jewelsea在評論中建議的那樣,你可以提供一個自定義的CellFactory來處理這個尺寸:
ComboBox<String> cb = new ComboBox<> ();
cb.setCellFactory(lv -> {
final ListCell<String> cell = new ListCell<> () {
@Override
public void updateItem(String item, boolean empty) /span> {
super.updateItem(item, empty)。
setText(item != null ? item : null)。)
}
};
Region icon = new Region()。
icon.getStyleClass().add("icon"/span>)。
cell.setGraphic(icon);
cell.setGraphicTextGap(20)。
return cell。
});
你可以在css中設定大小和樣式:
.combo-box-popup .list-view .list-cell .icon {
-fx-min-width: 10;
-fx-pref-width: 10;
-fx-max-width: 10;
-fx-min-height: 10;
-fx-pre-height: 10;
-fx-max-height: 10;
-fx-shape: "m184.405 461.013-184.405-184.405 24.354-24.354 160.051 160.051 332.279-332.279 24.354z";
-fx-background-color: white;
}
.combo-box-popup .list-view .list-cell {
-fx-content-display: text-only;
}
.combo-box-popup .list-view .list-cell:fill:selected {
-fx-content-display: right;
輸出:
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/331119.html
標籤:
上一篇:運算子多載抽象類
下一篇:沒有這樣的檔案或目錄:'Tensorflow/workspace/annotations\\label_map.pbtxtonJupyter為什么我的代碼不起作用?



