NoBugs
NoBugs

Reputation: 9512

Columns don't update in JTable

I'm using a JTable with AbstractTableModel:

_model = new AbstractTableModel() {

            @Override
            public int getColumnCount() {
                return _columns.size();
            }
            @Override
            public int getRowCount() {
                return _data.size();
            }
            @Override
            public Object getValueAt(int row, int col) {
                return _data.get(row)[col];
            }

            @Override
            public String getColumnName(int i) {
                return _columns.get(i);
            }
        };

When rows and columns change, calling table.revalidate() only shows changes to rows. Columns are exactly the same as before. Is there a way to force update for the whole table?

Upvotes: 0

Views: 554

Answers (2)

Ashwinee K Jha
Ashwinee K Jha

Reputation: 9317

If you change columns you should call fireTableStructureChanged on the model.

Upvotes: 2

Mike
Mike

Reputation: 1899

shouldn't it be

   @Override
                public Object getValueAt(int row, int col) {
                    return _data.get[row][col];
                }

Upvotes: 0

Related Questions