2017-02-11 6 views

ответ

3

Используйте метод getRowCount(). Вот вам один пример:

import javax.swing.JTable; 
public class Main { 
    public static void main(String[] argv) throws Exception { 
    Object[][] cellData = { { "1-1", "1-2" }, { "2-1", "2-2" } }; 
    String[] columnNames = { "col1", "col2" }; 

    JTable table = new JTable(cellData, columnNames); 

    int rows = table.getRowCount(); 
    int cols = table.getColumnCount(); 

    System.out.println(rows); 
    System.out.println(cols); 
    } 
} 

См: http://www.java2s.com/Tutorial/Java/0240__Swing/GettingtheNumberofRowsandColumnsinaJTableComponent.htm