排序后禁用JTableHeader更新
我定制了一个带有tablecellrenderer的JTable标头,因此会出现过滤器图标,并且当用户单击过滤器图标时,出现像Excel的弹出滤镜(图1)。但是,如果用户单击标题的文本,则使用了一个行分落器。当应用行选拔器(图2)时,它覆盖自定义和过滤器图标消失。是否有一种方法可以避免在将行分隔器保存在桌标题上的同时?
I customized a Jtable headers with a TableCellRenderer so filter icon would appear, and as the user clicks on the filter icon, a pop-up filter like excel's appears (picture 1). However, if the user clicks on the text of the header, a row sorter is appliead. When the row sorter is applied (picture 2), it override the customization and filter icon disappears. Is there a way to avoid this behavior while keeping the row sorter on the table header?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过使用自定义渲染标头的原始渲染器进行装饰,从而添加所需的过滤图标。
例如,遵循一些代码在原始列标头旁边添加自己的标签时保留排序图标:
而不是单词 filter (显示在每个列标题上)您可以在改为创建标签。
参考:
You can do this by decorating the original renderer of the table header with a custom one which will add the desired icon of filtering.
For example, follows some code to preserve the sort icons while adding your own label next to the original column header:
Instead of the word Filter (which appears on each column header) you can use your icons on the created label instead.
References: