Class TableUtilities

java.lang.Object
org.jdesktop.swingx.table.TableUtilities

public class TableUtilities extends Object
Collection of utility methods for J/X/Table.
Author:
Jeanette Winzenburg, Berlin
  • Method Details

    • isDataChanged

      public static boolean isDataChanged(TableModelEvent e)
      Returns a boolean indication whether the event represents a dataChanged type.
      Parameters:
      e - the event to examine.
      Returns:
      true if the event is of type dataChanged, false else.
    • isUpdate

      public static boolean isUpdate(TableModelEvent e)
      Returns a boolean indication whether the event represents a update type.
      Parameters:
      e - the event to examine.
      Returns:
      true if the event is a true update, false otherwise.
    • isInsert

      public static boolean isInsert(TableModelEvent e)
      Returns a boolean indication whether the event represents a insert type.
      Parameters:
      e - the event to examine
      Returns:
      true if the event is of type insert, false otherwise.
    • isDelete

      public static boolean isDelete(TableModelEvent e)
      Returns a boolean indication whether the event represents a remove type.
      Parameters:
      e - the event to examine
      Returns:
      true if the event is of type remove, false otherwise.
    • isStructureChanged

      public static boolean isStructureChanged(TableModelEvent e)
      Returns a boolean indication whether the event represents a structureChanged type.
      Parameters:
      e - the event to examine.
      Returns:
      true if the event is of type structureChanged or null, false else.
    • getPreferredRowHeight

      public static int getPreferredRowHeight(JTable table, int row)
      Returns the preferred height for the given row. It loops across all visible columns and returns the maximal pref height of the rendering component. Falls back to the table's base rowheight, i f there are no columns or the renderers max is zeor.

      Parameters:
      table - the table which provides the renderers, must not be null
      row - the index of the row in view coordinates
      Returns:
      the preferred row height of
      Throws:
      NullPointerException - if table is null.
      IndexOutOfBoundsException - if the row is not a valid row index
    • setPreferredRowHeight

      public static void setPreferredRowHeight(JTable table, int row)
      Parameters:
      table - the table which provides the renderers, must not be null
      row - the index of the row in view coordinates
      Throws:
      NullPointerException - if table is null.
      IndexOutOfBoundsException - if the row is not a valid row index
    • setPreferredRowHeights

      public static void setPreferredRowHeights(JTable table)
      Sets preferred row heights for all visible rows.
      Parameters:
      table - the table to set row heights to
      Throws:
      NullPointerException - if no table installed.
    • ordinalsOf

      public static int[] ordinalsOf(Enum<?>... values)
      Returns an array containing the ordinals of the given values of an Enum.

      Convience for clients which define TableColumns as Enums (Issue #1304-swingx).

      Parameters:
      values - the enums to map to its ordinals
      Returns:
      an array of ordinals, guaranteed to be not null
    • clear

      public static void clear(TableColumnModel model, boolean includeHidden)
      Removes all columns of the given column model. Includes hidden columns as indicated by the includesHidden flag, the flag has no effect if the model is not of type TableColumnModelExt.

      Parameters:
      model - the column model to remove all columns from.
      includeHidden - indicates whether hidden columns should be removed as well, has no effect if model is not of type TableColumnModelExt.