use of javax.swing.table.TableRowSorter in project pcgen by PCGen.
the class JTableEx method setAutoCreateRowSorter.
@Override
public void setAutoCreateRowSorter(boolean autoCreateRowSorter) {
boolean oldValue = this.sortingEnabled;
this.sortingEnabled = autoCreateRowSorter;
if (sortingEnabled) {
TableModel model = getModel();
if (model instanceof SortableTableModel) {
setRowSorter(new SortableTableRowSorter((SortableTableModel) dataModel));
} else {
setRowSorter(new TableRowSorter(model));
}
}
firePropertyChange("autoCreateRowSorter", oldValue, autoCreateRowSorter);
}
use of javax.swing.table.TableRowSorter in project pcgen by PCGen.
the class JTableEx method setModel.
@Override
public void setModel(TableModel dataModel) {
if (dataModel == null) {
throw new IllegalArgumentException("Cannot set a null TableModel");
}
if (this.dataModel != dataModel) {
TableModel old = this.dataModel;
if (old != null) {
old.removeTableModelListener(this);
}
this.dataModel = dataModel;
dataModel.addTableModelListener(this);
tableChanged(new TableModelEvent(dataModel, TableModelEvent.HEADER_ROW));
firePropertyChange("model", old, dataModel);
if (getAutoCreateRowSorter()) {
if (dataModel instanceof SortableTableModel) {
super.setRowSorter(new SortableTableRowSorter((SortableTableModel) dataModel));
} else {
super.setRowSorter(new TableRowSorter(dataModel));
}
}
}
}
Aggregations