JTable中与JGoodies数据整理麻烦 [英] JTable with jgoodies sorting trouble

查看:208
本文介绍了JTable中与JGoodies数据整理麻烦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JTable中的排序功能阻塞问题;这个现在做搪塞业余时间开源项目的发展,为4个月。希望能指出到这里了正确的方向。

I've got a blocking problem with the sorting functionality of a JTable; this made stall the development of the spare time open source project for 4 months now. Hope to be pointed into the right direction here.

上下文:我正在扩大的 ps3mediaserver 添加媒体库 PMS-MLX 。媒体服务器的用户界面一直使用摆动完成。

Context: I'm working on extending the functionality of the ps3mediaserver to add a media library with pms-mlx. The UI of the media server has been done using swing.

问题:当JTable中列标题点击,一个看似随意的列被替代排序被点击的一种具有

Problem: When clicking on a column header in the JTable, a seemingly random column gets sorted instead of the one having been clicked.

当前实现:下面是被用于执行不同的组件和类的描述:

Current implementation: Here's the description of the different components and classes being used for the implementation:

  • ETable: As alternate row colours aren't supported by default in the JTable, I've switched to the ETable extending the JTable. Source comes from here
  • FileDisplayTable: This is the class creating the table. In the init() method, the sorting is being enabled with 'table.setAutoCreateRowSorter(true);'
  • FileDisplayTableCellRenderer: Exists to always align cell content on the left
  • FileDisplayTableColumnModel: Does some mapping between internal types and column names
  • FileDisplayTableAdapter: This class implements com.jgoodies.binding.adapter.AbstractTableAdapter to map the objects with the table columns.

可能的解决方案:


  • preferably,我想保持目前的执行情况,并找出如何正确排序,但我怀疑有人可以帮助我与!?另外他们是我不得不因为怪异的行为的增加code的某些位;他们在code评论

  • 备用选择是干脆改变JTable的另一个控制。我做了一些研究,但没找到我所期待的解决方案。的约束是

    • 它必须在一个秋千UI嵌入

    • preferably它应该支持数据绑定

    • 支持交替行的颜色

    • 行排序

    在某些时候,将有可能打开的编辑对话,其中该行的内容已被检索,可以编辑和保存时的行必须被更新。

    At some point it will be possible to open an editing dialogue, where the content of the row has to be retrieved, can be edited and when saved the row has to be updated.

    重做整个事情之前,我想,以确保该组件将能处理所有我想用它做。

    Before reworking the entire thing I'd like to be sure the component will be able to handle all I want to do with it.

    我更用来创建在Visual Studio .NET使用图形用户界面。这是相当不同的,很多更难做同样的挥杆。请告诉我,我错了:)

    I'm more used to create GUIs using .NET in Visual Studio. It's quite different and a lot more difficult to do the same with swing. Please show me I'm wrong :)

    如果有人愿意重现该问题,要么得到源或二进制文件,启动应用程序,浏览媒体库选项卡。在GENRAL部分加入一些视频文件导入一些影片。去图书馆部分,点击应用即可刷新列表并尝试对表格进行排序。

    [edit] If someone is willing to reproduce the problem, either get the source or the binaries, launch the application, navigate to the media library tab. In the Genral section import some videos by adding some video files. Go to the library section, click on apply to refresh the list and try to sort the table.

    推荐答案

    这可能是有益的知道,的JTable 栏可以由用户拖动。其结果是,该视图(的JTable 或子类)和模式(的实施的TableModel )可能会有不同的列数字。同样, RowSorter的可能会影响视图相对于模型行的顺序或号码。相关的转换方法中提到如何使用表:排序和过滤。尤其是:当使用分拣机,永远记住翻译单元坐标。

    It may be useful to know that JTable columns can be dragged by the user. As a result, the view (JTable or a subclass) and model (an implementation of TableModel) may have different column numbers. Similarly, a RowSorter may affect the order or number of rows in the view as compared to the model. The related conversion methods are mentioned in How to Use Tables: Sorting and Filtering. In particular: "When using a sorter, always remember to translate cell coordinates."

    附录:作为一种替代方法,可以考虑<一个href=\"http://bits.netbeans.org/dev/javadoc/org-netbeans-swing-outline/org/netbeans/swing/etable/ETable.html\"相对=nofollow> org.netbeans.swing.etable.ETable 或它的子类<一个href=\"http://bits.netbeans.org/dev/javadoc/org-netbeans-swing-outline/org/netbeans/swing/outline/Outline.html\"相对=nofollow> org.netbeans.swing.outline.Outline ,所描绘的这里

    Addendum: As an alternative, consider org.netbeans.swing.etable.ETable or it's subclass org.netbeans.swing.outline.Outline, depicted here.

    这篇关于JTable中与JGoodies数据整理麻烦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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