如何在1.6中禁用JTable中的所有排序代码 [英] How can you disable all sorting code in JTable in 1.6

查看:204
本文介绍了如何在1.6中禁用JTable中的所有排序代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JTable扩展,自项目中的Java 1.3 / 1.4以来一直在使用,通过单击列提供列重新排序和排序等功能。我们正在升级到Java 1.6,新的JTable阻止旧的排序代码工作。将所有东西都安装到新的JTable API上会有些广泛的修改。在那之前有没有办法在JTable中完全禁用这些添加?

I have a JTable extension that has been in use since Java 1.3/1.4 in the project that provided things like column reordering and sorting by clicking on the column. We are upgrading to Java 1.6, and the new JTable stops the old sorting code from working. It would be somewhat extensive rework to fit everything to the new JTable API. Until then is there a way to completely disable those additions in JTable?

编辑:经过进一步调查后,问题集中在标题上的鼠标事件这一事实在1.6中被Swing吞噬,并且没有传递给表实现,即使它设置了自己的头部渲染。非常适合吹嘘的Java向后兼容性。

After the further investigation, the problem is centered around the fact that the mouse events on the header are swallowed by Swing in 1.6, and not passed on to the table implementation, even though it sets its own header rendered. So much for vaunted Java backwards compatibility.

那么有没有办法让JTable 1.6停止?我无法做到。甚至覆盖表上的UI和表头也无济于事。

So is there a way to get JTable 1.6 to stop? I haven't been able to. Even overriding the UI on the table and the table header didn't help.

推荐答案

你试过 JTable。 setRowSorter(null)

编辑 setAutoCreateRowSorter ? (1.创建表,2。行分类器为null,3。自动创建分拣机为假,4。设置模型)。

edit : and setAutoCreateRowSorter ? (1. create table, 2. row sorter to null, 3. autocreate sorter to false, 4. set model).

这篇关于如何在1.6中禁用JTable中的所有排序代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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