ArrayList表(125X6)需要在JTable中显示

时间:2013-05-30 07:18:36

标签: java swing arraylist jtable defaulttablemodel

我已将excel数据存储在arrayList对象中并将其发送到sendReportinTable(ArrayList list),但执行表为空。在JTable中找不到数据

String[] columnNames = {"TEST CASE NUMBER", "NO OF EXECUTION", "TOTAL NO OF PASSED", "TOTAL NO OF FAILED", "FINAL RESULT", "DATE & TIME"};
DefaultTableModel model = new DefaultTableModel(columnNames, 0);

public ReportTable() {
    super(new GridLayout(1, 0));

    final JTable table = new JTable(model);

    table.setPreferredScrollableViewportSize(
            new Dimension(1010, 500));
    table.setFillsViewportHeight(
            false);

    JScrollPane scrollPane = new JScrollPane(table);
    add(scrollPane);
}

void sendReportinTable(ArrayList list) {

    for (Object item : list) {
        Object[] row = new Object[6];
        for (int j = 0; j < 6; j++) {
            row[j] = (Object) item;
        }
        System.out.println("OUTPUT : -" + row);
        model.addRow(row);
    }
}

0 个答案:

没有答案