Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JTable remove column (index moves)

843804Nov 2 2004 — edited Nov 3 2004
Is there an easy way to remove a column without having to keep track of what columns have already been removed? What I mean is that if I have a table that I remove a column from the next column becomes the index of the removed one. So if I want to remove the first 2 columns I can just call:
TableColumnModel columnModel1 = table1.getColumnModel();
columnModel1.removeColumn( columnModel1.getColumn( 0 ) );
columnModel1.removeColumn( columnModel1.getColumn( 0 ) );
But then if I have to remove columns 1, 5, 9, 12 it gets a little annoying keeping track of what the 'new' index becomes of the columns I want to delete...
Isn't there an easier way?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 1 2004
Added on Nov 2 2004
5 comments
166 views