This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes JTable  column header Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable  column header" Watch "JTable  column header" New topic

JTable column header

Nick Kocher

Joined: Nov 24, 2004
Posts: 14

this should be an easy question but I'm stuck

is there any method to change the Column names of a JTable after creating it?(Sure there is)

to get the name of the Column,we can use the method of AbstractTableModel getColumnName(int col). is that right?

any help is appreciated
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
With the table, getColumnModel and with this get a reference to the TableColumn you want to change. Then call column.setHeaderValue.

If you want to change all of the column headers you can use one of the DefaultTableModel methods setColumnIdentifiers.
[ December 16, 2004: Message edited by: Craig Wood ]
I agree. Here's the link:
subject: JTable column header