ex1
Class TableSorter2
java.lang.Object
javax.swing.table.AbstractTableModel
ex1.TableSorter2
- All Implemented Interfaces:
- java.io.Serializable, javax.swing.table.TableModel
- public class TableSorter2
- extends javax.swing.table.AbstractTableModel
When the tableHeader property is set, either by using the
setTableHeader() method or the two argument constructor, the
table header may be used as a complete UI for TableSorter.
The default renderer of the tableHeader is decorated with a renderer
that indicates the sorting status of each column. In addition,
a mouse listener is installed with the following behavior:
-
Mouse-click: Clears the sorting status of all other columns
and advances the sorting status of that column through three
values: {NOT_SORTED, ASCENDING, DESCENDING} (then back to
NOT_SORTED again).
-
SHIFT-mouse-click: Clears the sorting status of all other columns
and cycles the sorting status of the column through the same
three values, in the opposite order: {NOT_SORTED, DESCENDING, ASCENDING}.
-
CONTROL-mouse-click and CONTROL-SHIFT-mouse-click: as above except
that the changes to the column do not cancel the statuses of columns
that are already sorting - giving a way to initiate a compound
sort.
- See Also:
- Serialized Form
Fields inherited from class javax.swing.table.AbstractTableModel |
listenerList |
Constructor Summary |
TableSorter2()
|
TableSorter2(javax.swing.table.TableModel tableModel)
|
TableSorter2(javax.swing.table.TableModel tableModel,
javax.swing.table.JTableHeader tableHeader)
|
Methods inherited from class javax.swing.table.AbstractTableModel |
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
tableModel
protected javax.swing.table.TableModel tableModel
DESCENDING
public static final int DESCENDING
- See Also:
- Constant Field Values
NOT_SORTED
public static final int NOT_SORTED
- See Also:
- Constant Field Values
ASCENDING
public static final int ASCENDING
- See Also:
- Constant Field Values
TableSorter2
public TableSorter2()
TableSorter2
public TableSorter2(javax.swing.table.TableModel tableModel)
TableSorter2
public TableSorter2(javax.swing.table.TableModel tableModel,
javax.swing.table.JTableHeader tableHeader)
getTableModel
public javax.swing.table.TableModel getTableModel()
setTableModel
public void setTableModel(javax.swing.table.TableModel tableModel)
getTableHeader
public javax.swing.table.JTableHeader getTableHeader()
setTableHeader
public void setTableHeader(javax.swing.table.JTableHeader tableHeader)
isSorting
public boolean isSorting()
getSortingStatus
public int getSortingStatus(int column)
setSortingStatus
public void setSortingStatus(int column,
int status)
getHeaderRendererIcon
protected javax.swing.Icon getHeaderRendererIcon(int column,
int size)
modelIndex
public int modelIndex(int viewIndex)
getRowCount
public int getRowCount()
getColumnCount
public int getColumnCount()
getColumnName
public java.lang.String getColumnName(int column)
getColumnClass
public java.lang.Class getColumnClass(int column)
isCellEditable
public boolean isCellEditable(int row,
int column)
getValueAt
public java.lang.Object getValueAt(int row,
int column)
setValueAt
public void setValueAt(java.lang.Object aValue,
int row,
int column)