I have a table that contains some data. I know that I can access of my first row like this,
Object nameOfFile = Main_Menu.jTable3.getValueAt(0, 0);
String nameOfFileToString = nameOfFile.toString();
My table is dynamic. Sometimes my row of the table is 100, sometimes is 200. How can I get the last row of my table even my table is dynamically change.
PS : my table is connected with a jfreechart, so I need this for my update Y axis in jfreechart like this
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
);
for the help, thanks
You can use JTable.getModel().getRowCount()
to get the number of rows; the rest is straightforward:
Object nameOfFile = Main_Menu.jTable3.getValueAt(jTable3.getModel().getRowCount()-1, 0);
// go on with your code
Thank you so much for all of you. This code is rock
Object nameOfFile = Main_Menu.jTable3.getValueAt(jTable3.getModel().getRowCount()-1, 0);
Now, my application is looking fine. I haven't try getrowSorter but soon I will try. Once again, thanks...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.