排序箭头jtable列标题 [英] sorting arrows jtable column header

查看:98
本文介绍了排序箭头jtable列标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道如何在对JTable列标题进行行排序时实现它的上下箭头吗?

我已经做出了自己的排序方式,它是通过mouseadapter监听鼠标点击而触发的,剩下的唯一是标题上的这种箭头的可见性 ...

还有没有一种方法可以轻松实现可排序的jtable?


我完成了所有排序,最后我无法做的就是显示排序箭头.

我不想制作一个新的,但是我没有找到是否有setEnableArrow之类的东西.

对此有什么想法吗?

解决方案

您可以查看)以及如何设置该图标(setIcon(sortIcon);)

Does anyone know how to implement the up and down arrows of a JTable column header while sorting its rows?

I have made my own way of sorting and it is triggered by listening to mouse clicks by mouseadapter and the only things that is left is the visibility of such arrows on the header...

Is there also a way to easily implement a sortable jtable?


I finished doing all the sorting and one last thing that i can't do is show the sorting arrows..

i don't want to make a new one but i failed to find if there is an setEnableArrow or something..

any ideas about this?

解决方案

You can take a look in the source code of the DefaultTableCellHeaderRenderer. In the getTableCellRendererComponent you see from where those icons are retrieved (e.g. UIManager.getIcon("Table.ascendingSortIcon")) and how this icon is set (setIcon(sortIcon);)

这篇关于排序箭头jtable列标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆