get JTable Data - Java Swing

Java examples for Swing:JTable

Description

get JTable Data

Demo Code


//package com.java2s;
import javax.swing.*;

public class Main {
    public static Object[][] getTableData(JTable table) {
        int rowCount = table.getRowCount();
        int columnCount = table.getModel().getColumnCount();
        Object[][] data = new Object[rowCount][columnCount];
        for (int i = 0; i < rowCount; i++) {
            for (int c = 0; c < columnCount; c++) {
                data[i][c] = table.getValueAt(i, c);
            }/*  w w  w.java2 s  .co  m*/
        }
        return data;
    }
}

Related Tutorials