public final class ListSortUI extends Object
This implementation is an adaption of JTable.SortManager fit to the needs of a ListUI. In contrast to JTable tradition, the ui delegate has full control about listening to model/selection changes and updating the list accordingly. So the role of this class is that of a helper to the ListUI (vs. as a helper of the JTable).
It's up to the ListUI to listen to model/selection and propagate the notification to this class if a sorter is installed, but still do the usual updates (layout, repaint) itself. On the other hand, listening to the sorter and updating list state accordingly is completely done by this.
| Constructor and Description |
|---|
ListSortUI(JXList list,
RowSorter<? extends ListModel> sorter)
Intanstiates a SortUI on the list which has the given RowSorter.
|
| Modifier and Type | Method and Description |
|---|---|
protected RowSorterListener |
createRowSorterListener()
Creates and returns a RowSorterListener.
|
void |
dispose()
Disposes any resources used by this SortManager.
|
void |
modelChanged(ListDataEvent e)
Called after notification from ListModel.
|
protected void |
sortedChanged(RowSorterEvent e)
Called after notification from RowSorter.
|
void |
viewSelectionChanged(ListSelectionEvent e)
Called after notification from selectionModel.
|
public ListSortUI(JXList list, RowSorter<? extends ListModel> sorter)
list - the list to control, must not be nullsorter - the rowSorter of the list, must not be nullNullPointerException - if either the list or the sorter is nullIllegalStateException - if the sorter is not the sorter installed
on the listpublic void dispose()
public void modelChanged(ListDataEvent e)
e - the change event from the listModel.public void viewSelectionChanged(ListSelectionEvent e)
protected void sortedChanged(RowSorterEvent e)
e - RowSorter event of type SORTED.protected RowSorterListener createRowSorterListener()
Copyright © 2019. All rights reserved.