-1

I have object like

class Person extends Human implements Serializable{ //just random example
String name;
CheckBox check;

//other functions with checkbox and name
}

and I want to serialize whole CheckBox object. I found out that it´s not possible for Java FX elements but is there any workaround around that if I want to serialize only one Java FX object per instance?

Thanks for answers.

  • 2
    don't use nodes as data (they are not serializable and there is hardly any reason for them to be), here instead use a plain boolean – kleopatra Apr 21 '21 at 10:13

1 Answers1

-3

original answer here

TableColumn<User, CheckBox> userSelected;

userSelected.setCellValueFactory(arg0 -> {
            User user = arg0.getValue();
            CheckBox checkBox = new CheckBox();
            checkBox.selectedProperty().setValue(user.isSelected());
            checkBox.selectedProperty().addListener((ov, old_val, new_val) -> user.setSelected(new_val));
            return new SimpleObjectProperty<>(checkBox);
        });
    tableView.getColumns().addAll(userSelected);
  • 1
    repeating: it's __wrong__ to have nodes as data! Instead use `TableColumn` with cell visualizing the boolean as checkBox (either custom or CheckBoxTableCell) – kleopatra Apr 21 '21 at 12:02