【发布时间】:2017-04-06 09:42:01
【问题描述】:
我已将 Listview 设置为 CheckBoxListCell。现在我需要在每行中添加一个颜色选择器来更改每个 ListCell 的颜色。我不知道我可以将它放入 CheckBoxListCell 的哪个位置。
ListView my_list = new ListView();
my_list.setCellFactory(CheckBoxListCell.forListView(new Callback<Item, ObservableValue<Boolean>>() {
@Override
public ObservableValue<Boolean> call(Item item) {
return item.onProperty();
}
}));
public class Item {
private final StringProperty name = new SimpleStringProperty();
private final BooleanProperty on = new SimpleBooleanProperty();
public Item(String name, boolean on) {
setName(name);
setOn(on);
}
public final StringProperty nameProperty() {
return this.name;
}
public final String getName() {
return this.nameProperty().get();
}
public final void setName(final String name) {
this.nameProperty().set(name);
}
public final BooleanProperty onProperty() {
return this.on;
}
public final boolean isOn() {
return this.onProperty().get();
}
public final void setOn(final boolean on) {
this.onProperty().set(on);
}
@Override
public String toString() {
return getName();
}
}
【问题讨论】:
标签: java listview javafx color-picker