Class SortableTableModel
- All Implemented Interfaces:
TableModel
-
Constructor Summary
ConstructorsConstructorDescriptionSortableTableModel(int column, boolean asc, TableModel model, Comparator cmp) Sorts a table based on the given column -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener to the data changed eventgetCellType(int row, int column) Allows the table to hint the class type of a specific cellintReturns the number of columns in the tablegetColumnName(int i) Returns the name of the column at the given offsetString[]getMultipleChoiceOptions(int row, int column) Allows the table cell to feature multiple choice for a specific entryintReturns the number of rows in the tableintgetSortedPosition(int row) Returns the position of the row when sortedReturns the underlying table modelgetValidationConstraint(int row, int column) If the cell has a validation constraint it's returned hereA validator can be defined here so a validation constraint can bind to a table model cellgetValueAt(int row, int column) Returns the value of the cell at the given locationbooleanisCellEditable(int row, int column) Returns true if the cell at the given location is an editable cellvoidRemoves a listener to the data changed eventvoidsetValidator(Validator validator) A validator can be defined here so a validation constraint can bind to a table model cellvoidsetValueAt(int row, int column, Object o) Sets the value of the cell at the given location
-
Constructor Details
-
SortableTableModel
Sorts a table based on the given column
Parameters
-
column: the column to sort -
asc: the direction ascending/descending -
model: the underlying model that will be sorted -
cmp: a comparator used for comparing the cells in the column
-
-
-
Method Details
-
getUnderlying
Returns the underlying table model
Returns
the model
-
getSortedPosition
public int getSortedPosition(int row) Returns the position of the row when sorted
Parameters
row: 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
Returns the name of the column at the given offset
Parameters
i: 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
-
row: the cell row -
column: the cell column
Returns
true if the cell at the given location is an editable cell
-
-
getValueAt
Returns the value of the cell at the given location
Parameters
-
row: the cell row -
column: the cell column
Returns
the value of the cell at the given location
-
-
setValueAt
Sets the value of the cell at the given location
Parameters
-
row: the cell row -
column: the cell column -
o: the value of the cell at the given location
-
-
addDataChangeListener
Adds a listener to the data changed event
Parameters
d: the new listener
-
removeDataChangeListener
Removes a listener to the data changed event
Parameters
d: the listener to remove
-
getValidationConstraint
If the cell has a validation constraint it's returned here
Parameters
-
row: the row -
column: the column for the cell
Returns
null for no constraints
- Overrides:
getValidationConstraintin classAbstractTableModel
-
-
getCellType
Allows the table to hint the class type of a specific cell
Parameters
-
row: the row in the table -
column: the column
Returns
the class representing this cell
- Overrides:
getCellTypein classAbstractTableModel
-
-
getMultipleChoiceOptions
Allows the table cell to feature multiple choice for a specific entry
Parameters
-
row: the row in the table -
column: the column
Returns
- Overrides:
getMultipleChoiceOptionsin classAbstractTableModel- Returns:
- the string values matching the entries or null if this isn't a multiple choice option
-
-
getValidator
Description copied from class:AbstractTableModelA validator can be defined here so a validation constraint can bind to a table model cell
Returns
the validator
- Overrides:
getValidatorin classAbstractTableModel
-
setValidator
Description copied from class:AbstractTableModelA validator can be defined here so a validation constraint can bind to a table model cell
Parameters
validator: the validator to set
- Overrides:
setValidatorin classAbstractTableModel
-