I am new to JavaFX
and would like to know how to set and get the cell value of JavaFX
Table like Swing
JTable
. i.e. an alternative of setValueAt()
& getValueAt
of Swing
JTable
in JavaFX
Table.
//would like to get the index of column by Name
int index_RunnableQueueItem = tableQueue.getColumns().indexOf("RunnableQueueItem");
//would like to get the selected row
int row = tableQueue.getSelectionModel().getSelectedIndex();
if (index_RunnableQueueItem != -1 && row != -1) {
// would like to get the value at index of row and column.
//Update that value and set back to cell.
}
TableView really doesn't support this methodology.
Here's a somewhat brittle means of doing what you want, using reflection. It's entirely dependent upon you using PropertyValueFactory in your cell value factory so it can lookup the property name, though.
Retrieving a simple value from a JavaFx TableView Cell
You can use listeners as listed in other posts, but if you wish to get just a simple value from a cell you can use a simpler method
Hope this expample helps you.