简体   繁体   中英

glazed lists - default sorting?

I'm working with the Glazed List tutorial found here and here , but the implication is that you need a comparator to sort rows. However, I can't seem to figure out how to add support for sorting based on table header clicks.

After more trial and error, I've found what I was doing wrong.

The EventTableModel must be instantiated with the SortedList instance, not the EventList . From the example:

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());

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM