JavaFX使用表索引获取单元数据的最简单方法 [英] JavaFX Simplest way to get cell data using table index

查看:159
本文介绍了JavaFX使用表索引获取单元数据的最简单方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有最简单的方法在不使用cellfactory函数的情况下使用表索引值在javafx中获取tableview的单元格数据。我看起来像这样简单的单行代码

Is there any simplest way to get cell data of a tableview in javafx using table index values without using cellfactory function.Iam looking simple single line code like this

  getValueAt(1,2);//1=column number 2=row number

所以我可以访问column = 1和row = 2的单元格数据。提前谢谢

So i can access the cell data on column=1 and row=2.Thanks in advance

推荐答案

你可以使用 TableColumn 获取observable,并在其上使用 getValue

You can get the observable using the TableColumn and use getValue on it:

public static Object getValueAt(TableView table, int column, int row) {
    return table.getColumns().get(column).getCellObservableValue(row).getValue();
}

这篇关于JavaFX使用表索引获取单元数据的最简单方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆