Package ucar.ui.table

Class JTableSorted

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, Accessible

    public class JTableSorted
    extends JPanel
    JTableSorted adds sorting functionality to a JTable. It also wraps the JTable in a JScrollPane. Note that JTableSorted is a JPanel, and has-a JTable. It throws ListSelectionEvent events when the selection changes. It throws a UIChangeEvent, property = "sort" just before a sort is going to happen.
    See Also:
    Serialized Form
    • Constructor Detail

      • JTableSorted

        public JTableSorted​(String[] colName,
                            ArrayList listRT)
        Constructor.
        Parameters:
        colName - list of column names
        listRT - list of rows. This must contain objects that implement the TableRow interface. May be null or empty.
      • JTableSorted

        public JTableSorted​(String[] columnName,
                            ArrayList listRT,
                            boolean enableColumnManipulation,
                            ThreadSorter threadSorter)
        Constructor.
        Parameters:
        columnName - list of column names
        listRT - list of rows. This must contain objects that implement the TableRow interface. May be null or empty.
        enableColumnManipulation - allow columns to be added, deleted via click-right popup
        threadSorter - if not null, add a "thread sorting" column
    • Method Detail

      • sort

        public void sort​(int colNo,
                         boolean reverse)
        Sort the rowList: note rowList changed, not a copy of it.
        Parameters:
        colNo - sort on this column
        reverse - if true, reverse sort
      • setList

        public void setList​(ArrayList rowList)
        Replace the rowList with this one.
        Parameters:
        rowList - list of rows
      • removeRow

        public void removeRow​(Object elem)
        Remove elem from rowList, update the table. Searches for match using object identity (==)
        Parameters:
        elem - which element
      • addListSelectionListener

        public void addListSelectionListener​(ListSelectionListener l)
        add ListSelectionEvent listener
      • removeListSelectionListener

        public void removeListSelectionListener​(ListSelectionListener l)
        remove ListSelectionEvent listener
      • addUIChangeListener

        public void addUIChangeListener​(UIChangeListener l)
        add UIChangeEvent listener
      • removeUIChangeListener

        public void removeUIChangeListener​(UIChangeListener l)
        remove UIChangeEvent listener
      • getSelectedRowIndex

        public int getSelectedRowIndex()
      • setSortOK

        public void setSortOK​(boolean sortOK)
      • getSelected

        public TableRow getSelected()
        Get the currently selected row.
        Returns:
        selected TableRow
      • setSelected

        public void setSelected​(int row)
        Set the current selection to this row.
        Parameters:
        row - index into rowList
      • incrSelected

        public void incrSelected​(boolean increment)
        Increment or decrement the current selection by one row.
        Parameters:
        increment - true=increment, false=decrement
      • getTable

        public JTable getTable()
        Get the JTable delegate so you can do nasty things to it
      • getModelIndex

        public int[] getModelIndex()
        for each column, get the model index