Java JTable Row Sort getSortOrder(@Nonnull RowSorter rowSorter, int column)

Here you can find the source of getSortOrder(@Nonnull RowSorter rowSorter, int column)

Description

Get the sort order for a column given a RowSorter for the TableModel containing the column.

License

Open Source License

Parameter

Parameter Description
rowSorter the sorter
column the column index in the model, not the view

Return

the sort order or .

Declaration

@Nonnull
public static SortOrder getSortOrder(@Nonnull RowSorter<? extends TableModel> rowSorter, int column) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.annotation.Nonnull;
import javax.swing.RowSorter;
import javax.swing.RowSorter.SortKey;
import javax.swing.SortOrder;

import javax.swing.table.TableModel;

public class Main {
    /**//from w  w w.  j  ava 2s .  c  o  m
     * Get the sort order for a column given a RowSorter for the TableModel
     * containing the column.
     *
     * @param rowSorter the sorter
     * @param column    the column index in the model, not the view
     * @return the sort order or {@link javax.swing.SortOrder#UNSORTED}.
     */
    @Nonnull
    public static SortOrder getSortOrder(@Nonnull RowSorter<? extends TableModel> rowSorter, int column) {
        for (SortKey key : rowSorter.getSortKeys()) {
            if (key.getColumn() == column) {
                return key.getSortOrder();
            }
        }
        return SortOrder.UNSORTED;
    }
}

Related

  1. addSingleSortableColumnListener( @Nonnull RowSorter rowSorter)
  2. applyRowSorter(JTable table)
  3. createTableRowSorter(Class clazz, TableModel model)
  4. filt(ArrayList selectedLevel, String text, TableRowSorter sorter)
  5. jtable$setAutoCreateRowSorter(JTable table)
  6. setSortOrder(@Nonnull RowSorter rowSorter, int column, @Nonnull SortOrder sortOrder)
  7. tryToEnableRowSorting(JTable listTbl)