Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable - custom JTableHeader with UP, DOWN sorting icon  RSS feed

 
Giri Thava
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class MyHeaderRenderer extends DefaultTableCellRenderer {
public MyHeaderRenderer() {
setIcon(new ImageIcon("1.png"));
setHorizontalAlignment(SwingConstants.CENTER);
setBackground(Color.YELLOW);
}
}

RowSorter<TableModel> sorter = new TableRowSorter<TableModel> (tableModel);
table.setRowSorter (sorter);
table.getColumnModel().getColumn(2).setHeaderRenderer(new MyHeaderRenderer());

After setting a custom header renderer, the default UP and DOWN sort image
is not displaying in the table header. How can I show those images.

Thanks in advance
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!