简体   繁体   English

可排序JTable标题的小三角形图标来自哪里?

[英]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. 我正在编写一个自定义组件,需要使用可排序JTable标头的小三角形图标。 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. 例如,在Windows外观中, WindowsTableHeaderUI查找以下内容以绘制相应的图标。 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. 虽然BasicLookAndFeel为这些属性注册了一个值(所以如果你使用类似的调用可能会有一些东西 ),正如@Michael Borgwardt指出的那样(通过从他的回答中得出结论),因为任何给定的结果都不能保证这一点。外观可能会选择放弃UIManager并绘制自己的图形。

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. Paiting这些将是一个子类的工作TableHeaderUI具体到当前的外观和感觉。 One L&F might load it from a file while another paints it as a vector graphic. 一个L&F可能会从文件加载它,而另一个L&F将其绘制为矢量图形。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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