Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTABLE header question - make BOLD

 
Long Huynh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I was wondering how can I change the headers of a JTable to be BOLD, instead of the defualt plain type?
thanks
 
Long Huynh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i tried this, but it isn't working.
JTableHeader header = MACTable.getTableHeader();
TableCellRenderer renderer = header.getDefaultRenderer();
Component comp = renderer.getTableCellRendererComponent(MACTable, null, false, false,
0, 0);
Font f = comp.getFont();
Font boldFont = f.deriveFont(Font.BOLD);
comp.setFont(boldFont);
 
Ashish Gupta
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Long,
Try this it should work for you.

where
ETableModel is a class that extends AbstractTableModel.
Ashish
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic