How to get the number of rows and columns in a JTable

Leave a Comment
The following methods are used to get  the number of rows and columns in a table in java

getColumnCount():Above method is used for getting the number of columns in the column model that returns integer type values.

getRowCount():This method returns integer types value that is number of rows in the model of table.

JTable table = new JTable(model);
  System.out.println("Number of Columns: "
table.getColumnCount();
//the above code will output the number of columns
  System.out.println("Number of Rows: "+ table.getRowCount());
this line will output the number of rows


0 comments:

Post a Comment