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 header 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 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
It's not a secret anymore!