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!

how to change JTable column header text

RichFDec 9 2010 — edited Dec 9 2010
How do you set the text in the JTable column headers? I know you can create a JTable specifying the text in an array:

<li>JTable(Object[][] rowData, Object[] columnNames)

But if you create the JTable specifying a TableModel,

<li>JTable(TableModel dm)

the header text defaults to "A", "B", "C", etc. I cannot figure out how to access the text in the header names so it can be changed to something useful. I know how to get the JTableHeader for the table, but it does not seem to have methods for actually setting header values.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 6 2011
Added on Dec 9 2010
8 comments
4,268 views