com.dlsc.flexgantt.swing.util

## Class TableUtils

- java.lang.Object
- - com.dlsc.flexgantt.swing.util.TableUtils

-     public class TableUtils
      extends Object

  Utility methods for use with `JTable`.
  Since:
    1.0
  Version:
    $Revision: 1.8 $
  Author:
    Dirk Lemmermann

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `TableUtils()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static int` | `autoResizeTable(JTable table, boolean includeColumnHeaderWidth)` Resizes the given table so that all of its columns have their preferred width.
    `static int` | `autoResizeTable(JTable table, boolean includeColumnHeaderWidth, int columnPadding)` Resizes the given table so that all of its columns have their preferred width.
    `static void` | `ensureRowIsVisible(JTable table, int row)` Scrolls the viewport to make the specified row vertically completely visible.
    `static void` | `repaintAfterValueChanged(JComponent comp, TreeTable table, TreeSelectionEvent e)` Repaints the given component after a value changed event from the tree table selection model has arrived.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### TableUtils

          public TableUtils()

  - ### Method Detail

    - #### autoResizeTable

          public static int autoResizeTable(JTable table,
                                            boolean includeColumnHeaderWidth)

      Resizes the given table so that all of its columns have their preferred width. This preferred width is the maximum width used by any one of the table cells (plus an additional column padding).
      Parameters:
        `table` - the table to resize
        `includeColumnHeaderWidth` - a flag that signals whether the width of the column header shall be considered as well
      Returns:
        the calculated preferred width of the table
      Since:
        1.0

    - #### autoResizeTable

          public static int autoResizeTable(JTable table,
                                            boolean includeColumnHeaderWidth,
                                            int columnPadding)

      Resizes the given table so that all of its columns have their preferred width. This preferred width is the maximum width used by any one of the table cells.
      Parameters:
        `table` - the table to resize
        `includeColumnHeaderWidth` - a flag that signals whether the width of the column header shall be considered as well
        `columnPadding` - a padding added to the preferred column width
      Returns:
        the calculated preferred width of the table
      Since:
        1.0

    - #### repaintAfterValueChanged

          public static void repaintAfterValueChanged(JComponent comp,
                                                      TreeTable table,
                                                      TreeSelectionEvent e)

      Repaints the given component after a value changed event from the tree table selection model has arrived. This utility method gets used by the row headers, the tree table, and the layer container when they receive this event and need to repaint. This method ensures that only the affected rows get repainted.
      Parameters:
        `comp` - the component that needs repainting
        `table` - the table where the selection event occured
        `e` - the tree selection event that triggered the repaint
      Since:
        1.1

    - #### ensureRowIsVisible

          public static void ensureRowIsVisible(JTable table,
                                                int row)

      Scrolls the viewport to make the specified row vertically completely visible.
      Note, for this method to work, the `JTable` must be displayed within a `JViewport`.
      Parameters:
        `table` - The table to show the row for.
        `row` - The row to show.

Copyright © 2006–2020 Dirk Lemmermann Software & Consulting. All rights reserved.