Servis-Rhino 4211B Guide de l'utilisateur Page 274

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 298
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 273
be set to any nodes you like which will then appear in the table.
Again, a TableColumn has a CellFactory and a CellFactory returns a TableCell and
a TableCell knows how to render a cell.
An example of coding a setCellFactory() would then be:
actionsColumn.setCellFactory(new Callback<TableColumn<SearchResult, String>,TableCell<SearchResult,
String>>() {
@Override
public TableCell<SearchResult, String> call(TableColumn<SearchResult, String> column) {
final TableCell<SearchResult, String> cell = new TableCell<SearchResult, String>();
Button button = new Button("Hello");
cell.setGraphic(button);
return cell;
}
});
Using Java 8 Lambdas, we might have something like:
linesTableColumn.setCellFactory(tableColumn -> new TableCell<String, String>() {
@Override
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
if (!isEmpty()) {
setTextFill(Color.BLACK);
setStyle(null);
setFont(font);
setText(item);
} // End !is empty
} // End of updateItem
}); // End of setCellFactory
TableCell objects are re-used. There is not a TableCell object for event cell in a column.
Instead the TableView manages to create only those that are needed to show the table.
Let us take a different, but equally valid pass at describing the nature of the TableCell.
Imagine we have an array of data. That is illustrated in the following image. Do not confuse this
image with a table … it is meant to say we have an array of data.
Page 274
Vue de la page 273
1 2 ... 269 270 271 272 273 274 275 276 277 278 279 ... 297 298

Commentaires sur ces manuels

Pas de commentaire