Package weka.gui

Class JTableHelper

java.lang.Object
weka.gui.JTableHelper

public class JTableHelper extends Object
A helper class for JTable, e.g. calculating the optimal colwidth.
Version:
$Revision: 10216 $
Author:
FracPete (fracpete at waikato dot ac dot nz)
  • Constructor Details

    • JTableHelper

      public JTableHelper(JTable jtable)
      initializes the object
  • Method Details

    • getJTable

      public JTable getJTable()
      returns the JTable
    • calcColumnWidth

      public int calcColumnWidth(int col)
      calcs the optimal column width of the given column
    • calcColumnWidth

      public static int calcColumnWidth(JTable table, int col)
      Calculates the optimal width for the column of the given table. The calculation is based on the preferred width of the header and cell renderer.
      Taken from the newsgoup de.comp.lang.java with some modifications.
      Taken from FOPPS/EnhancedTable - http://fopps.sourceforge.net/
      Parameters:
      table - the table to calculate the column width
      col - the column to calculate the widths
      Returns:
      the width, -1 if error
    • calcHeaderWidth

      public int calcHeaderWidth(int col)
      calcs the optimal header width of the given column
    • calcHeaderWidth

      public static int calcHeaderWidth(JTable table, int col)
      Calculates the optimal width for the header of the given table. The calculation is based on the preferred width of the header renderer.
      Parameters:
      table - the table to calculate the column width
      col - the column to calculate the widths
      Returns:
      the width, -1 if error
    • setOptimalColumnWidth

      public void setOptimalColumnWidth(int col)
      sets the optimal column width for the given column
    • setOptimalColumnWidth

      public static void setOptimalColumnWidth(JTable jtable, int col)
      sets the optimal column width for the given column
    • setOptimalColumnWidth

      public void setOptimalColumnWidth()
      sets the optimal column width for all columns
    • setOptimalColumnWidth

      public static void setOptimalColumnWidth(JTable jtable)
      sets the optimal column width for alls column if the given table
    • setOptimalHeaderWidth

      public void setOptimalHeaderWidth(int col)
      sets the optimal header width for the given column
    • setOptimalHeaderWidth

      public static void setOptimalHeaderWidth(JTable jtable, int col)
      sets the optimal header width for the given column
    • setOptimalHeaderWidth

      public void setOptimalHeaderWidth()
      sets the optimal header width for all columns
    • setOptimalHeaderWidth

      public static void setOptimalHeaderWidth(JTable jtable)
      sets the optimal header width for alls column if the given table
    • scrollToVisible

      public void scrollToVisible(int row, int col)
      Assumes table is contained in a JScrollPane. Scrolls the cell (rowIndex, vColIndex) so that it is visible within the viewport.
    • scrollToVisible

      public static void scrollToVisible(JTable table, int row, int col)
      Assumes table is contained in a JScrollPane. Scrolls the cell (rowIndex, vColIndex) so that it is visible within the viewport.