首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >JavaFX TableView如何获取小区数据?

JavaFX TableView如何获取小区数据?
EN

Stack Overflow用户
提问于 2015-03-17 02:59:21
回答 6查看 42.7K关注 0票数 12

我用那个方法来得到整个物体。

代码语言:javascript
运行
复制
tableView.getSelectionModel().getSelectedItem()

如何从单细胞中获取数据?

我是说把S20BJ9DZ300266作为字符串?

EN

回答 6

Stack Overflow用户

回答已采纳

发布于 2015-03-17 03:45:30

假设你知道某件事是被选中的,你可以做

代码语言:javascript
运行
复制
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();
票数 20
EN

Stack Overflow用户

发布于 2018-12-28 18:05:54

假设你没有选择任何行,但知道你想要什么.

代码语言:javascript
运行
复制
// 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);
票数 4
EN

Stack Overflow用户

发布于 2016-01-03 19:43:20

代码语言:javascript
运行
复制
table.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
            if (newValue == null) {
                selected.setText("");
                return;
            }
                       System.out.println(newValue.getId());
        });

注意:"getId“是您的"get”列,"table“是您的表视图的名称。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29090583

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档