Servis-Rhino 4211B Guía de usuario Pagina 276

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 298
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 275
to set the table to be editable. By default, it is flagged as not editable. We can call:
myTable.setEditable(true)
to achieve this.
There is a lifecycle associated with cell editing. When one has finished editing the cell, the
column's onEditCommit() callback is invoked. This is responsible for hardening the change
back to the data when the edit completes.
To use this we would define a lambda callback such as:
myColumn.setOnEditCommit((CellEditEvent<DataClass, ColumnClass> t) -> {
// Update Data
});
Ok … so how do we know what to update? Well the CellEditEvent class contains a wealth of
information getters including:
getTableView() - The table view that was edited
getTablePosition() - A TablePosition that defines a row and a column
getNewValue() - The new value that was the result of the edit
So now we can do things like:
int changedRow = t.getTablePosition().getRow();
Person p = (Person)t.getTableView.getItems().get(changedRow);
p.setName(t.getNewValue());
Some convenience editors are provided:
TextFieldTableCell – Display a text input field.
CheckBoxTableCell – Display a check box field.
ChoiceBoxTableCell – Display a choice box showing a fixed set of options
ComboBoxTableCell
ProgressBarTableCell
See also:
JavaFX MultipleSelectionModel
Tutorial – JavaFX TableView
JavaFX TableView – Detecting selections
The TableView contains a property called "selectionModel" which can be retrieved via
"getSelectionModel()". Through this, we can register an interest in being told when a
selection change is made.
For example:
tableView.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) ->
{
// Handler code here
});
JavaFX TableView – Dynamic Columns
On occasion we may wish to dynamically add and remove columns. From an instance of a
Page 276
Vista de pagina 275
1 2 ... 271 272 273 274 275 276 277 278 279 280 281 ... 297 298

Comentarios a estos manuales

Sin comentarios