我用那个方法来得到整个物体。
tableView.getSelectionModel().getSelectedItem()
如何从单细胞中获取数据?
我是说把S20BJ9DZ300266作为字符串?
发布于 2015-03-17 03:45:30
假设你知道某件事是被选中的,你可以做
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();
发布于 2018-12-28 18:05:54
假设你没有选择任何行,但知道你想要什么.
// Item here is the table view type:
Unpaid item = userTable.getItems().get(0);
TableColumn col = userTable.getColumns().get(3);
// this gives the value in the selected cell:
String data = (String) col.getCellObservableValue(item).getValue();
JOptionPane.showMessageDialog(null, data);
发布于 2016-01-03 19:43:20
table.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
if (newValue == null) {
selected.setText("");
return;
}
System.out.println(newValue.getId());
});
注意:"getId“是您的"get”列,"table“是您的表视图的名称。
https://stackoverflow.com/questions/29090583
复制相似问题