Modifying a TableModel and updating the table

I am new to Swing, and have picked up a job to modify some Swing that draws a 2D table (a grid). I've added a form so the table configuration can be changed, which basically means that columns can be selected/de-selected.

I have the selection form working, and as I close this form with the OK button, I modify the Column Headers, which are stored in a Vector.

As I update the column headers I fire an fireTableStructureChanged(), which gets picked up by a TableModelListener in the class with my JTable. I then create a new TableModel object assigned to the same reference. The changed Column Headers should add only reqd. columns to the model.

I could do with some guidance as to what I need to do to get the JTable to work with the new Model.

(The code is a nightmare, so I'll spare you that pain, and be happy with just some guidance).

Any help is greatly appreciated.

Thanks

[924 byte] By [Stevefkia] at [2007-11-27 10:20:55]
# 1

JTable.setModel()

ejpa at 2007-7-28 17:06:33 > top of Java-index,Java Essentials,New To Java...
# 2

Yes, I had just got to that conclusion when you answered.

My Cells now display with the expected column configuration. However, the cells use a custom cell renderer, and instead of seeing the 'rendered' cell I see a blank cell with a reference to the object which holds the data. The data for each cell is held in an object holding a few data items. The Cell renderer has a simple grid to display these items. What I see is the full package name for the data object followed by @....... which looks to be an address, probably of the object.

So I conclude that the problem is that I have lost the Cell renderer reference somehow.

Stevefkia at 2007-7-28 17:06:33 > top of Java-index,Java Essentials,New To Java...