This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Icons on JTable header Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Icons on JTable header" Watch "Icons on JTable header" New topic

Icons on JTable header

Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
How to give icons on the JTable Header clicks.Example Up and Down arrows when clicking on the Headers.

Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
Create a DefaultTableCellRenderer. Because it extends form JLabel set its icon with setIcon method. Then assign it to render the header of a column by TableColumn.setHeaderRenderer.
TableHeader.setDefaultRenderer assigns a TableCellRenderer to any TableColumn on which the method above was not called.

SCJP2. Please Indent your code using UBB Code
Mathews P Srampikal
Ranch Hand

Joined: Nov 26, 2002
Posts: 211
Thank You.
I agree. Here's the link:
subject: Icons on JTable header