Here you can find the source of isColumnSorted(JTable table, int column)
Parameter | Description |
---|---|
table | - the table to check |
column | - the column in the table to check. |
public static boolean isColumnSorted(JTable table, int column)
//package com.java2s; import java.util.List; import javax.swing.JTable; import javax.swing.RowSorter; import javax.swing.RowSorter.SortKey; public class Main { /**/*from w ww . j a v a 2 s .c o m*/ * Returns whether a table column is sorted. * @param table - the table to check * @param column - the column in the table to check. * @return boolean - whether the column is sorted or not. */ public static boolean isColumnSorted(JTable table, int column) { boolean isSorted = false; final int modelColumn = table.convertColumnIndexToModel(column); RowSorter sorter = table.getRowSorter(); if (sorter != null) { List<? extends SortKey> sortKeys = sorter.getSortKeys(); for (SortKey sortKey : sortKeys) { if (sortKey.getColumn() == modelColumn) { isSorted = true; break; } } } return isSorted; } }