jQuery in Action, 3rd edition
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

Sharada Sreeram

Joined: Jan 15, 2001
Posts: 9
I want to make my JTable column header of a particular column as bold - I read JavaSoft's Look&Feel guidelines book, which suggests we do it (if we say sort the columns) but does not say how to.
Does anyone of you have any idea of how I could do this.
Thanks in advance,
Glen Tanner
Ranch Hand

Joined: Apr 16, 1999
Posts: 147

Column names are Strings, or probably more accurately JLabels, which recognize HTML tags.
So, a column name like "First Name", can be made "{html}{b}First Name{/b}{/html}"
[This message has been edited by Glen Tanner (edited January 17, 2001).]
Sharada Sreeram

Joined: Jan 15, 2001
Posts: 9
Actually I took care of this using table cell rendering. I was using the abstract table model without cell rendering - so, to set a particular column, I had to get that column (using JTable.getColumn()) and then use that TableColumns getHeaderRenderer/setHeaderRenderer to change the font for a particular column.
p.s Of course, your method is way more straightforward
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
But not nearly as cool.

"JavaRanch, where the deer and the Certified play" - David O'Meara
I agree. Here's the link: http://aspose.com/file-tools
subject: JTable Column header
It's not a secret anymore!