我正在使用该方法获取整个对象。
tableView.getSelectionModel().getSelectedItem()
如何从单个单元格中获取数据?
我的意思是像获取 S20BJ9DZ300266 作为字符串?
最佳答案
假设您知道某些内容已被选中,您可以这样做
TablePosition pos = table.getSelectionModel().getSelectedCells().get(0);
int row = pos.getRow();
// Item here is the table view type:
Item item = table.getItems().get(row);
TableColumn col = pos.getTableColumn();
// this gives the value in the selected cell:
String data = (String) col.getCellObservableValue(item).getValue();
关于JavaFX TableView 如何获取单元格的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29090583/