I'm working with sql and java. I created a JTable to filtrate information from database to there. I want to get the length of that JTable (number of rows) and print that result in a JLabel. How can I do that?
Thanks!
It's worth reading about How to Use Tables and find more sample code on it.
Sample code:
TableModel dataModel = new AbstractTableModel() {
public int getRowCount() { return rowData.length; }
...
// override other method as well
}
JTable table = new JTable(dataModel);
JScrollPane scrollpane = new JScrollPane(table);
Simply call the DefaultTableModel#getRowCount() method to get the number of rows.
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.