Package weka.gui
Class JTableHelper
java.lang.Object
weka.gui.JTableHelper
A helper class for JTable, e.g. calculating the optimal colwidth.
- Version:
- $Revision: 10216 $
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
calcColumnWidth
(int col) calcs the optimal column width of the given columnstatic int
calcColumnWidth
(JTable table, int col) Calculates the optimal width for the column of the given table.int
calcHeaderWidth
(int col) calcs the optimal header width of the given columnstatic int
calcHeaderWidth
(JTable table, int col) Calculates the optimal width for the header of the given table.returns the JTablevoid
scrollToVisible
(int row, int col) Assumes table is contained in a JScrollPane.static void
scrollToVisible
(JTable table, int row, int col) Assumes table is contained in a JScrollPane.void
sets the optimal column width for all columnsvoid
setOptimalColumnWidth
(int col) sets the optimal column width for the given columnstatic void
setOptimalColumnWidth
(JTable jtable) sets the optimal column width for alls column if the given tablestatic void
setOptimalColumnWidth
(JTable jtable, int col) sets the optimal column width for the given columnvoid
sets the optimal header width for all columnsvoid
setOptimalHeaderWidth
(int col) sets the optimal header width for the given columnstatic void
setOptimalHeaderWidth
(JTable jtable) sets the optimal header width for alls column if the given tablestatic void
setOptimalHeaderWidth
(JTable jtable, int col) sets the optimal header width for the given column
-
Constructor Details
-
JTableHelper
initializes the object
-
-
Method Details
-
getJTable
returns the JTable -
calcColumnWidth
public int calcColumnWidth(int col) calcs the optimal column width of the given column -
calcColumnWidth
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 widthcol
- 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
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 widthcol
- 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
sets the optimal column width for the given column -
setOptimalColumnWidth
public void setOptimalColumnWidth()sets the optimal column width for all columns -
setOptimalColumnWidth
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
sets the optimal header width for the given column -
setOptimalHeaderWidth
public void setOptimalHeaderWidth()sets the optimal header width for all columns -
setOptimalHeaderWidth
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
Assumes table is contained in a JScrollPane. Scrolls the cell (rowIndex, vColIndex) so that it is visible within the viewport.
-