wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Delete column from TableModel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Delete column from TableModel" Watch "Delete column from TableModel" New topic
Author

Delete column from TableModel

Anthony Yip
Ranch Hand

Joined: Aug 24, 2003
Posts: 30
How I can delete a column from JTable's TableModel?
Please give me some idea. Thanks.
Regards
Anthony Yip
Dan Platon
Greenhorn

Joined: Jan 27, 2004
Posts: 4
Hello...
Can you give us more details ? You want to delete it programatically ? If som, can you paste some code from the table model you are using ?
Dan
Kiran More
Greenhorn

Joined: Dec 29, 2003
Posts: 10
If u r using DefaulttableModel then check API to delete column.Else modify the tablemodel u created to delete column, generally by removing the column information from vectors used to hold column info. .Set this new model as table model for the table.Generally table.setModel(new TableModel()) will refresh the view to show new table configuration.
[ February 04, 2004: Message edited by: Kiran More ]
Anthony Yip
Ranch Hand

Joined: Aug 24, 2003
Posts: 30
Yup I would like to popup a dialog by pressing a button for user to choosing a column to be deleted.
My TableModel is simple:
I have a TreeSet that storing data. Then,

Then, with some codes convert the data from the set to the above array. Then, instaniate a DefaultTableModel with the above array as arguments:

I have already used a showInputDialog to get a String that representing the column header from user. And then, locate the relevant TableColumn. But I don't know how to remove the column from the TableModel.
Could you give me some hints?
Tell me if you need more details.
Thanks
Regards
Anthony Yip
 
 
subject: Delete column from TableModel