Class TableHelper


  • public final class TableHelper
    extends Object
    The class that provide common JTable customization methods
    Since:
    5785
    • Method Detail

      • adjustColumnWidth

        public static void adjustColumnWidth​(JTable tbl,
                                             int col,
                                             boolean resizable)
        adjust the preferred width of column col to the maximum preferred width of the cells (including header)
        Parameters:
        tbl - table
        col - column index
        resizable - if true, resizing is allowed
        Since:
        15176
      • adjustColumnWidth

        public static void adjustColumnWidth​(JTable tbl,
                                             int col,
                                             int maxColumnWidth)
        adjust the preferred width of column col to the maximum preferred width of the cells (including header) requires JTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        Parameters:
        tbl - table
        col - column index
        maxColumnWidth - maximum column width
      • computeColumnsWidth

        public static void computeColumnsWidth​(JTable tbl)
        adjust the table's columns to fit their content best requires JTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        Parameters:
        tbl - table
        Since:
        14476
      • getSelectedIndices

        public static int[] getSelectedIndices​(ListSelectionModel selectionModel)
        Returns an array of all of the selected indices in the selection model, in increasing order. Unfortunately this method is not available in OpenJDK before version 11, see https://bugs.openjdk.java.net/browse/JDK-8199395 To be removed when we switch to Java 11 or later.
        Parameters:
        selectionModel - list selection model.
        Returns:
        all of the selected indices, in increasing order, or an empty array if nothing is selected
        Since:
        15226
        See Also:
        selectedIndices(ListSelectionModel)
      • selectedIndices

        public static IntStream selectedIndices​(ListSelectionModel selectionModel)
        Returns a stream of all of the selected indices in the selection model, in increasing order.
        Parameters:
        selectionModel - list selection model.
        Returns:
        all of the selected indices, in increasing order, or an empty stream if nothing is selected
        Since:
        17773