• Post Reply Bookmark Topic Watch Topic
  • New Topic

How do you change JTableHeader on the fly?  RSS feed

 
Sam Zheng
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JTable with one specific header. I want to change the header to another one in the program when a specific condition is satisfied. How can I do that?
Thanks!
Sam
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
table.getColumn( Object identifier ) or table.getColumnModel().getColumn( int index ) will get you a table column. Then use either setHeaderValue( Object value ) or setHeaderRenderer( TableCellRenderer renderer ) on the table column to make the appropriate changes. You may have to call invalidate(), validate(), or repaint() on the table to get the changes to show up...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!