0

I have a TableView with a CheckBoxTableCell column.

I would like to catch the selection of the cell and change the Cursor to Cursor.WAIT.

Clicking the cell will cause some db-query to happen, that will take a few seconds. I would like to notify the user that something is going on and the application did not just die.

@FXML
private TableColumn<IOrigin, Boolean> cActive;

@Override
public void initialize(final URL location, final ResourceBundle resources) {
cActive.setCellFactory(tc -> new CheckBoxTableCell<>());
[..]

}

Listening on CheckBoxTableCell#selectedProperty() does not work, it does not fire any change events.

The column cells are bound to a bean property via fxml.

<TableColumn text="Active" editable="true" fx:id="cActive">
<cellValueFactory>
<PropertyValueFactory property="active" />
/cellValueFactory>
</TableColumn>
kerner1000
  • 3,382
  • 1
  • 37
  • 57
  • What does `updateItem(...)` have to do with selection? – James_D Apr 06 '17 at 19:26
  • Nothing, but this one I could override respectively change the cursor before and after. But when this method is called, all the work is already done. – kerner1000 Apr 06 '17 at 19:27
  • http://stackoverflow.com/questions/43274939/javafx-how-do-i-trigger-an-event-if-someone-check-a-checkbox-in-tableview – SedJ601 Apr 07 '17 at 13:20
  • Possible duplicate of [JavaFX: CheckBoxTableCell get ActionEvent when user check a checkBox](https://stackoverflow.com/questions/28671132/javafx-checkboxtablecell-get-actionevent-when-user-check-a-checkbox) – SedJ601 Oct 25 '19 at 19:16

1 Answers1

0

With the cells show CheckBox in TableView:

  • Note that the CheckBoxTableCell renders the CheckBox 'live', meaning that the CheckBox is always interactive and can be directly toggled by the user.
  • This means that it is not necessary that the cell enter its editing state (usually by the user double-clicking on the cell).
  • A side-effect of this is that the usual editing callbacks (such as on edit commit) will not be called.
  • If you want to be notified of changes, it is recommended to directly observe the boolean properties that are manipulated by the CheckBox.
SedJ601
  • 12,173
  • 3
  • 41
  • 59
  • I understand. But observing "the boolean properties that are manipulated.." means observing the model object for a UI task. That is a bit smelly and will require major refactorings so the "scene" object is available to the model. – kerner1000 Apr 07 '17 at 09:46