org.yasl.tables
Class YASLTableUtils

java.lang.Object
  extended byorg.yasl.tables.YASLTableUtils

public class YASLTableUtils
extends Object

Utils class for standalone table methods.


Field Summary
static int DISPLAY_ALL_ROWS
           
 
Method Summary
static Dimension adjustPreferredColumnWidths(JTable table)
          Adjusts preferred column widths so that columns widths will be just wide enough to accomodate the content and the heading.
static Dimension adjustPreferredColumnWidths(JTable table, int visibleRows, int veticalScrollBarWidth, boolean setScrollableViewport)
          Adjusts preferred column widths so that columns widths will be just wide enough to accomodate the content and the heading.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISPLAY_ALL_ROWS

public static final int DISPLAY_ALL_ROWS
See Also:
Constant Field Values
Method Detail

adjustPreferredColumnWidths

public static Dimension adjustPreferredColumnWidths(JTable table)
Adjusts preferred column widths so that columns widths will be just wide enough to accomodate the content and the heading.

IMPORTANT: Call this method after the table model has been set.

Code drawn from Swing Hacks, 2005.

Parameters:
table - JTable
Returns:
Dimension -- preferred table width and height

adjustPreferredColumnWidths

public static Dimension adjustPreferredColumnWidths(JTable table,
                                                    int visibleRows,
                                                    int veticalScrollBarWidth,
                                                    boolean setScrollableViewport)
Adjusts preferred column widths so that columns widths will be just wide enough to accomodate the content and the heading.

Caller can specify the number of visible rows. This will affect the preferred table height returned in the Dimension object. An average row height is calculated then multiplied by the number of visible rows. Passing the constant DISPLAY_ALL_ROWS will result in a preferred table height that includes all the rows.

If your table is likely to have a vertical scrollbar, the table width needs to account for it. Call the following methods on your JScrollPane instance to the get the scroll bar width.
getVerticalScrollBar().getMaximumSize().width

If true is passed for the setScrollableViewport argument, the setPreferredScrollableViewportSize method will be called on the passed JTable instance.

IMPORTANT: Call this method after the table model has been set.

Code drawn from Swing Hacks, 2005.

Parameters:
table - JTable
visibleRows - int
veticalScrollBarWidth - int
setScrollableViewport - boolean
Returns:
Dimension -- preferred table width and height