【问题标题】:glazed lists - default sorting?釉面列表 - 默认排序?
【发布时间】:2012-05-12 08:41:19
【问题描述】:

我正在使用 here 和 here 的 Glazed List 教程,但这意味着您需要一个比较器来对行进行排序。但是,我似乎无法弄清楚如何添加对基于表头点击的排序的支持。

【问题讨论】:

  • 你在 JTable 上使用 autocreaterowsorter 吗?
  • 不,我不知道那是什么。你能解释一下吗?

标签: java glazedlists


【解决方案1】:

经过更多的尝试和错误,我发现我做错了什么。

EventTableModel 必须使用 SortedList 实例,而不是 EventList。示例:

private EventList<Issue> issuesEventList = new BasicEventList<Issue>();
...

        SortedList<Issue> sortedIssues = new SortedList<Issue>(issuesEventList, null);

        // create a panel with a table
        JPanel panel = new JPanel();
        // be careful not to put issuesEventList in here, it has to be the sortedIssues list
        EventTableModel<Issue> issuesTableModel = new EventTableModel<Issue>(sortedIssues, new IssueTableFormat());

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-11-21
    • 1970-01-01
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多