简体   繁体   中英

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

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.

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.

Paiting those would be the job of a subclass of TableHeaderUI specific to the current Look-and-Feel. One L&F might load it from a file while another paints it as a vector graphic.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM