public class SortableTableModel
- Object
- AbstractTableModel
- SortableTableModel
ImplementsTableModel
A proxy that wraps the table model providing sorting API that can be leveraged by the table
Constructors
public SortableTableModel(int column, boolean asc, TableModel model, Comparator cmp) | Sorts a table based on the given column |
Methods
Inherited methods
Constructor details
SortableTableModel
public SortableTableModel(int column, boolean asc, TableModel model, Comparator cmp)Sorts a table based on the given column
Parameters
columnint- the column to sort
ascboolean- the direction ascending/descending
modelTableModel- the underlying model that will be sorted
cmpComparator- a comparator used for comparing the cells in the column
Method details
getUnderlying
public TableModel getUnderlying()Returns the underlying table model
Returns
the model
getSortedPosition
public int getSortedPosition(int row)Returns the position of the row when sorted
Parameters
rowint- the row in the visual table
Returns
the position in the underlying model
getRowCount
public int getRowCount()Returns the number of rows in the table
Returns
the number of rows in the table
getColumnCount
public int getColumnCount()Returns the number of columns in the table
Returns
the number of columns in the table
getColumnName
public String getColumnName(int i)Returns the name of the column at the given offset
Parameters
iint- the offset for the column name
Returns
name to display at the top of the table
isCellEditable
public boolean isCellEditable(int row, int column)Returns true if the cell at the given location is an editable cell
Parameters
rowint- the cell row
columnint- the cell column
Returns
true if the cell at the given location is an editable cell
getValueAt
public Object getValueAt(int row, int column)Returns the value of the cell at the given location
Parameters
rowint- the cell row
columnint- the cell column
Returns
the value of the cell at the given location
setValueAt
public void setValueAt(int row, int column, Object o)Sets the value of the cell at the given location
Parameters
rowint- the cell row
columnint- the cell column
oObject- the value of the cell at the given location
addDataChangeListener
public void addDataChangeListener(DataChangedListener d)Adds a listener to the data changed event
Parameters
dDataChangedListener- the new listener
removeDataChangeListener
public void removeDataChangeListener(DataChangedListener d)Removes a listener to the data changed event
Parameters
dDataChangedListener- the listener to remove
getValidationConstraint
public Constraint getValidationConstraint(int row, int column)If the cell has a validation constraint it’s returned here
Parameters
rowint- the row
columnint- the column for the cell
Returns
null for no constraints
getCellType
public Class getCellType(int row, int column)Allows the table to hint the class type of a specific cell
Parameters
rowint- the row in the table
columnint- the column
Returns
the class representing this cell
getMultipleChoiceOptions
public String[] getMultipleChoiceOptions(int row, int column)Allows the table cell to feature multiple choice for a specific entry
Parameters
rowint- the row in the table
columnint- the column
Returns
the string values matching the entries or null if this isn’t a multiple
choice option
getValidator
public Validator getValidator()A validator can be defined here so a validation constraint can bind to a table model cell
Returns
the validator
setValidator
public void setValidator(Validator validator)A validator can be defined here so a validation constraint can bind to a table model cell
Parameters
validatorValidator- the validator to set