File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes JTable Column View Order Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable Column View Order" Watch "JTable Column View Order" New topic

JTable Column View Order

Balachandran Paranjothimani
Ranch Hand

Joined: Jun 18, 2005
Posts: 43
I have a JTable that gets the number and sequence of columns from options menu. The user can select which fields must be displayed in the table as well as its order.

I have extended the AbstractTableModel class to implement the getValue, setValue and other methods.

In order to hide the columns that the user has not selected in the options I am using table.getColumnModel().removeColumn(table.getColumn(columnName)); This just hides the column from the view but it is still in the model.

The problem is how to rearrage the view order of the columns during runtime? The user can change the order anytime and the display must reflect those changes. Any ideas on how I can do this? TIA.

Moderator : <a href="" target="_blank" rel="nofollow"></a><br />Home : <a href="" target="_blank" rel="nofollow"></a>
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
I agree. Here's the link:
subject: JTable Column View Order
It's not a secret anymore!