In JavaFX, you use TableColumn with CellFactories and CellValueFactories to populate a TableView .
There is an article in JavaFX tutorials that can help you get started.
In one of the approaches that I used, I convert business objects for display into presentation objects and add to them all the necessary properties (for example, in your case, a number).
EDIT: in a second, TableCell approach, you can configure CellFactory to create a TableCell , which displays its own index property in TableCell#updateItem(S, boolean) :
public class NumberedCell extends TableCell{ protected void updateItem(Object object, boolean selected){ setText(String.valueOf(getIndex()); } }
Urs reupke
source share