Search in sources :

Example 31 with TableRowSorter

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);
}
Also used : SortableTableRowSorter(pcgen.gui2.util.table.SortableTableRowSorter) SortableTableModel(pcgen.gui2.util.table.SortableTableModel) SortableTableModel(pcgen.gui2.util.table.SortableTableModel) TableModel(javax.swing.table.TableModel) TableRowSorter(javax.swing.table.TableRowSorter) SortableTableRowSorter(pcgen.gui2.util.table.SortableTableRowSorter)

Example 32 with TableRowSorter

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));
            }
        }
    }
}
Also used : TableModelEvent(javax.swing.event.TableModelEvent) SortableTableRowSorter(pcgen.gui2.util.table.SortableTableRowSorter) SortableTableModel(pcgen.gui2.util.table.SortableTableModel) SortableTableModel(pcgen.gui2.util.table.SortableTableModel) TableModel(javax.swing.table.TableModel) TableRowSorter(javax.swing.table.TableRowSorter) SortableTableRowSorter(pcgen.gui2.util.table.SortableTableRowSorter)

Aggregations

TableRowSorter (javax.swing.table.TableRowSorter)32 JTable (javax.swing.JTable)23 JScrollPane (javax.swing.JScrollPane)22 JPanel (javax.swing.JPanel)17 JLabel (javax.swing.JLabel)15 BoxLayout (javax.swing.BoxLayout)13 JButton (javax.swing.JButton)13 TableColumnModel (javax.swing.table.TableColumnModel)10 Dimension (java.awt.Dimension)9 ActionEvent (java.awt.event.ActionEvent)9 SystemNameComparator (jmri.util.SystemNameComparator)9 ActionListener (java.awt.event.ActionListener)8 TableColumn (javax.swing.table.TableColumn)8 TableModel (javax.swing.table.TableModel)7 ButtonEditor (jmri.util.table.ButtonEditor)6 ButtonRenderer (jmri.util.table.ButtonRenderer)6 BorderLayout (java.awt.BorderLayout)5 FlowLayout (java.awt.FlowLayout)5 Point (java.awt.Point)5 JComboBox (javax.swing.JComboBox)5