allensoft.gui
Class SortedTableModel
java.lang.Object
|
+--javax.swing.table.AbstractTableModel
|
+--allensoft.gui.SortedTableModel
- All Implemented Interfaces:
- java.io.Serializable, javax.swing.table.TableModel
- public class SortedTableModel
- extends javax.swing.table.AbstractTableModel
A TableModel that sorts the data contained in another table model.
- See Also:
- Serialized Form
Fields inherited from class javax.swing.table.AbstractTableModel |
listenerList |
Method Summary |
void |
addMouseListenerToHeaderInTable(javax.swing.JTable table)
|
java.lang.Class |
getColumnClass(int columnIndex)
Returns the most specific superclass for all the cell values
in the m_nColumn. |
int |
getColumnCount()
Returns the number of columns in the model. |
java.lang.String |
getColumnName(int columnIndex)
Returns the name of the m_nColumn at columnIndex . |
java.util.Comparator |
getComparator()
|
javax.swing.table.TableModel |
getModel()
|
int |
getRowCount()
Returns the number of rows in the model. |
int |
getSortColumn()
|
java.lang.Object |
getValueAt(int rowIndex,
int columnIndex)
Returns the value for the cell at columnIndex and
rowIndex . |
boolean |
isAscending()
|
boolean |
isCellEditable(int rowIndex,
int columnIndex)
Returns true if the cell at rowIndex and
columnIndex
is editable. |
void |
resort()
|
void |
setComparator(java.util.Comparator comparator)
|
void |
setValueAt(java.lang.Object aValue,
int rowIndex,
int columnIndex)
Sets the value in the cell at columnIndex and
rowIndex to aValue . |
void |
sortByColumn(int nColumn,
boolean bAscending)
|
Methods inherited from class javax.swing.table.AbstractTableModel |
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, removeTableModelListener |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SortedTableModel
public SortedTableModel(javax.swing.table.TableModel model,
java.util.Comparator comparator)
SortedTableModel
public SortedTableModel(javax.swing.table.TableModel model)
getComparator
public java.util.Comparator getComparator()
setComparator
public void setComparator(java.util.Comparator comparator)
sortByColumn
public void sortByColumn(int nColumn,
boolean bAscending)
resort
public void resort()
getModel
public javax.swing.table.TableModel getModel()
getSortColumn
public int getSortColumn()
isAscending
public boolean isAscending()
getRowCount
public int getRowCount()
- Returns the number of rows in the model. A
JTable
uses this method to determine how many rows it
should display. This method should be quick, as it
is called frequently during rendering.
- Overrides:
getRowCount
in class javax.swing.table.AbstractTableModel
- Returns:
- the number of rows in the model
- See Also:
getColumnCount()
getColumnCount
public int getColumnCount()
- Returns the number of columns in the model. A
JTable
uses this method to determine how many columns it
should create and display by default.
- Overrides:
getColumnCount
in class javax.swing.table.AbstractTableModel
- Returns:
- the number of columns in the model
- See Also:
getRowCount()
getColumnName
public java.lang.String getColumnName(int columnIndex)
- Returns the name of the m_nColumn at
columnIndex
. This is used
to initialize the table's m_nColumn header name. Note: this name does
not need to be unique; two columns in a table can have the same name.
- Overrides:
getColumnName
in class javax.swing.table.AbstractTableModel
- Parameters:
columnIndex
- the index of the m_nColumn- Returns:
- the name of the m_nColumn
getColumnClass
public java.lang.Class getColumnClass(int columnIndex)
- Returns the most specific superclass for all the cell values
in the m_nColumn. This is used by the
JTable
to set up a
default renderer and editor for the m_nColumn.
- Overrides:
getColumnClass
in class javax.swing.table.AbstractTableModel
- Parameters:
columnIndex
- the index of the m_nColumn- Returns:
- the common ancestor class of the object values in the model.
isCellEditable
public boolean isCellEditable(int rowIndex,
int columnIndex)
- Returns true if the cell at
rowIndex
and
columnIndex
is editable. Otherwise, setValueAt
on the cell will not
change the value of that cell.
- Overrides:
isCellEditable
in class javax.swing.table.AbstractTableModel
- Parameters:
rowIndex
- the row whose value to be queriedcolumnIndex
- the m_nColumn whose value to be queried- Returns:
- true if the cell is editable
- See Also:
setValueAt(java.lang.Object, int, int)
getValueAt
public java.lang.Object getValueAt(int rowIndex,
int columnIndex)
- Returns the value for the cell at
columnIndex
and
rowIndex
.
- Overrides:
getValueAt
in class javax.swing.table.AbstractTableModel
- Parameters:
rowIndex
- the row whose value is to be queriedcolumnIndex
- the m_nColumn whose value is to be queried- Returns:
- the value Object at the specified cell
setValueAt
public void setValueAt(java.lang.Object aValue,
int rowIndex,
int columnIndex)
- Sets the value in the cell at
columnIndex
and
rowIndex
to aValue
.
- Overrides:
setValueAt
in class javax.swing.table.AbstractTableModel
- Parameters:
aValue
- the new valuerowIndex
- the row whose value is to be changedcolumnIndex
- the m_nColumn whose value is to be changed- See Also:
getValueAt(int, int)
,
isCellEditable(int, int)
addMouseListenerToHeaderInTable
public void addMouseListenerToHeaderInTable(javax.swing.JTable table)