Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does the little triangle icon of sortable JTable header come from?

Tags:

java

swing

I am writting a customized component which need to use the little triangle icon of sortable JTable header. Maybe it's not really an icon file but a graphics painted by some class.

like image 227
solotim Avatar asked Dec 05 '22 03:12

solotim


1 Answers

I believe the sort icon comes from the look and feel. For example, in the Windows look and feel, the WindowsTableHeaderUI looks up the following to draw the appropriate icon. For ascending:

UIManager.getIcon("Table.ascendingSortIcon");

For descending:

UIManager.getIcon("Table.descendingSortIcon");

While the BasicLookAndFeel registers a value for these properties (so there is likely to be something there if you use a similar call), as @Michael Borgwardt notes (by drawing a conclusion from his answer), there is no guarantee of this since any given look and feel might choose to forego the UIManager and draw their own graphics.

Still, it might be worthwhile trying it to see if it does what you want.

like image 84
Ash Avatar answered Feb 09 '23 01:02

Ash