|
StocksMonitor 1.5.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
ObjectObservable
TableSortIndicator
final class TableSortIndicator
Places an up or down icon in a table column header, as an indicator of the primary sort.
This class does not do any sorting of the underlying rows - it merely indicates the identity and direction of the sorted column.
The user changes the indicated sort by simply clicking on a column header. The initial click always indicates a descending sort. A re-click on the same column will toggle the indicated direction.
Listeners to this class are notified when the sort has changed, and
use getSortBy() to retrieve the new sort, and then perform the actual
sorting. Example :
TableSortIndicator fSortIndicator = new TableSortIndicator(table, upIcon, downIcon);
fSortIndicator.addObserver(this);
//when the user clicks a column header, fSortIndicator will notify
//registered observers, who will call getSortBy to fetch the new sort.
//..
public void update(Observable aObservable, Object aData) {
//extract column and (asc|desc) from fSortIndicator
SortBy sortBy = fSortIndicator.getSortBy();
//...perform the actual sorting
}
Instead of using a mouse click, the sort can be set programmatically as well; this
is useful for reflecting a sort selected through a preferences dialog. Example :
TableSortIndicator fSortIndicator = new TableSortIndicator(table, upIcon, downIcon); fSortIndicator.addObserver(this); fSortIndicator.setSortBy( sortByPreference ) ; //setSortBy calls the update method
| Constructor Summary | |
|---|---|
TableSortIndicator(JTable aTable,
Icon aUpIcon,
Icon aDownIcon)
Constructor. |
|
| Method Summary | |
|---|---|
(package private) SortBy |
getSortBy()
Return the identity of column having the primary sort, and the direction of its sort. |
(package private) void |
setSortBy(SortBy aTargetSort)
Change the sort programmatically, instead of through a user click. |
| Methods inherited from class Observable |
|---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
TableSortIndicator(JTable aTable,
Icon aUpIcon,
Icon aDownIcon)
aTable - receives indication of table sort ; if it has any custom
header renderers, they will be overwritten by this class.aUpIcon - placed in column header to indicate ascending sort.aDownIcon - placed in column header to indicate descending sort.| Method Detail |
|---|
SortBy getSortBy()
void setSortBy(SortBy aTargetSort)
If there is a user preference for sort, it is passed to this method. Notifies listeners of the change to the sort.
|
StocksMonitor 1.5.0 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||