Chapter 2. Sorting, Tables & Sorting Tables

Table of Contents

SortedList, a transformed list
Comparators, Comparable and SortedList
Using TableFormat to specify columns
The EventTableModel and TableComparatorChooser
So What?

In part two of this tutorial we apply a sorted transformation to our issues list. We construct a JTable to display the list with a column for each important attribute of the Issue class. Finally we add support to sort our JTable by the clicking on its column headers.

SortedList, a transformed list

The SortedList is simply a wrapper that shows another EventList in sorted order. Like all TransformedLists, the SortedList listens for changes to its source list and adjusts itself when changes are made. By layering TransformedLists like SortedList and AbstractFilterList, we are able to create flexible and powerful programs easily.