Forums Register Login

JTable - custom JTableHeader with UP, DOWN sorting icon

+Pie Number of slices to send: Send
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
It was the best of times. It was the worst of times. It was a tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 3347 times.
Similar Threads
JTable rowFilter - is case insensitive possible?
B&S using a sorted column table to display the records? How many of you have done this?
Moving editable columns in a JTable
Trouble with JTable sorting dates.
Problem with sorting and filtering a JTable
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 04:18:11.