tags:

views:

75

answers:

2

I have a static 2D array called "Status.Data[][]" and a Column header called "Status.Columns[]"

I am using net beans and I want to be able to have the arrays populate the table.

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        jTable1.setColumnModel(new DefaultColumnModel(Status.Data, Status.Columns));
    }

This throws an error that it is expecting a TableColumnModel.

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        jTable1.setColumnModel(new TableColumnModel(Status.Data, Status.Columns));
    }

This says java.swing.table.TableColumnModel is abstract and cannot be instaniated.

I would even be happy if I could figure out how to make it display when the window is opened.

How do I populate my table?

+1  A: 

You can create the table model and then pass it to the table constructor:

TableModel model = new DefaultTableModel(Status.Data, Status.Columns);
JTable table = new JTable(model);
Guillaume
+1  A: 

use javax.swing.table.DefaultTableModel

DefaultTableModel(Object[][] data, Object[] columnNames)
naikus