I had the same problem for CheckBoxTableCell and DatePickerTableCell and ColorPickerTableCells: - (
I mean the following: in control events, I return POJO objects that are used by " ((Inputs) getTableView (). GetItems (). Get (getTableRow (). GetIndex () ", and I update the similar one as it is done in OnEditCommit method ...
So for me it looks like this (refresh the color):
((Inputs) getTableView().getItems().get( getTableRow().getIndex()) ).setColor(cp.getValue());
Here is an example with ColorPickerCell
public class ColorPickerTableCell<Inputs> extends TableCell<Inputs, Color>{ private ColorPicker cp; public ColorPickerTableCell(){ cp = new ColorPicker(); cp.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { commitEdit(cp.getValue()); updateItem(cp.getValue(), isEmpty()); ((Inputs) getTableView().getItems().get( getTableRow().getIndex()) ).setColor(cp.getValue()); } }); setGraphic(cp); setContentDisplay(ContentDisplay.GRAPHIC_ONLY); setEditable(true); } @Override protected void updateItem(Color item, boolean empty) { super.updateItem(item, empty); cp.setVisible(!empty); this.setItem(item); cp.setValue(item); } }
With this simple JavaFX POJO:
public ObjectProperty<Color> color = new SimpleObjectProperty<Color>(); this.color = new SimpleObjectProperty(color); public ObjectProperty<Color> colorProperty() { return color; } public void setColor(Color color2) { color.set(color2); }
I donβt know if this is a good way to achieve this, but it worked for me ... Please note that JavaFX POJO is only available in the "ActionEvent" request (combobox, datepicker, colorpicker, etc.)
Hi,
source share