[英]How to get the value of last row in jtable
我有一个包含一些数据的表。 我知道我可以像这样访问我的第一行,
Object nameOfFile = Main_Menu.jTable3.getValueAt(0, 0);
String nameOfFileToString = nameOfFile.toString();
我的桌子是动态的。 有时我的表的行是100,有时是200。即使我的表是动态更改的,如何获取表的最后一行。
PS:我的表与jfreechart连接,所以我需要像这样在jfreechart中更新Y轴
Object nameOfFile = Main_Menu.jTable3.getValueAt(0, 0);
String nameOfFileToString = nameOfFile.toString();
// create the chart...
final JFreeChart chart = ChartFactory.createLineChart(
"Persentastion Of Similarity", // chart title
"", // domain axis label
nameOfFileToString, // range axis label
dataset, // data
PlotOrientation.VERTICAL, // orientation
true, // include legend
true, // tooltips
false // urls
);
的帮助,谢谢
您可以使用JTable.getModel().getRowCount()
来获取行数。 其余的很简单:
Object nameOfFile = Main_Menu.jTable3.getValueAt(jTable3.getModel().getRowCount()-1, 0);
// go on with your code
非常感谢大家。 这段代码是摇滚
Object nameOfFile = Main_Menu.jTable3.getValueAt(jTable3.getModel().getRowCount()-1, 0);
现在,我的应用程序看起来不错。 我没有尝试过getrowSorter,但很快我会尝试。 再次感谢...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.