Just as we have transformed our source list to be sorted, we will transform the
sorted list to be filtered. The JTable will display the
filtered list which is already sorted. We will also add the filter editing
JTextField to our panel.
/**
* Display a frame for browsing issues.
*/
public void display() {
SortedList sortedIssues = new SortedList(issuesEventList, new IssueComparator());
TextFilterList textFilteredIssues = new TextFilterList(sortedIssues, new IssueTextFilterator());
// create a panel with a table
JPanel panel = new JPanel();
panel.setLayout(new GridBagLayout());
EventTableModel issuesTableModel = new EventTableModel(textFilteredIssues, new IssueTableFormat());
JTable issuesJTable = new JTable(issuesTableModel);
TableComparatorChooser tableSorter = new TableComparatorChooser(issuesJTable, sortedIssues, true);
JScrollPane issuesTableScrollPane = new JScrollPane(issuesJTable);
panel.add(new JLabel("Filter: "), new GridBagConstraints(...));
panel.add(textFilteredIssues.getFilterEdit(), new GridBagConstraints(...));
panel.add(issuesTableScrollPane, new GridBagConstraints(...));
// create a frame with that panel
JFrame frame = new JFrame("Issues");
frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
frame.setSize(540, 380);
frame.getContentPane().add(panel);
frame.show();
}