Groovy Documentation

com.wordpress.tipsforjava.swing
[Java] Class TableColumnAdjuster

java.lang.Object
  com.wordpress.tipsforjava.swing.TableColumnAdjuster
All Implemented Interfaces:
PropertyChangeListener, TableModelListener

public class TableColumnAdjuster
extends Object

Class to manage the widths of colunmns in a table. Various properties control how the width of the column is calculated. Another property controls whether column width calculation should be dynamic. Finally, various Actions will be added to the table to allow the user to customize the functionality. This class was designed to be used with tables that use an auto resize mode of AUTO_RESIZE_OFF. With all other modes you are constrained as the width of the columns must fit inside the table. So if you increase one column, one or more of the other columns must decrease. Because of this the resize mode of RESIZE_ALL_COLUMNS will work the best.

Authors:
Rob Camick
Darryl Burke


Nested Class Summary
class TableColumnAdjuster.ColumnAction

class TableColumnAdjuster.ToggleAction

 
Field Summary
private Map columnSizes

private boolean isColumnDataIncluded

private boolean isColumnHeaderIncluded

private boolean isDynamicAdjustment

private boolean isOnlyAdjustLarger

private int spacing

private JTable table

 
Constructor Summary
TableColumnAdjuster(JTable table)

TableColumnAdjuster(JTable table, int spacing)

 
Method Summary
void adjustColumn(int column)

void adjustColumns()

private int getCellDataWidth(int row, int column)

private int getColumnDataWidth(int column)

private int getColumnHeaderWidth(int column)

private void installActions()

private void installColumnAction(boolean isSelectedColumn, boolean isAdjust, String key, String keyStroke)

private void installToggleAction(boolean isToggleDynamic, boolean isToggleLarger, String key, String keyStroke)

void propertyChange(PropertyChangeEvent e)

private void restoreColumn(int column)

void restoreColumns()

void setColumnDataIncluded(boolean isColumnDataIncluded)

void setColumnHeaderIncluded(boolean isColumnHeaderIncluded)

void setDynamicAdjustment(boolean isDynamicAdjustment)

void setOnlyAdjustLarger(boolean isOnlyAdjustLarger)

void tableChanged(TableModelEvent e)

private void updateTableColumn(int column, int width)

 
Methods inherited from class Object
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll
 

Field Detail

columnSizes

private Map columnSizes


isColumnDataIncluded

private boolean isColumnDataIncluded


isColumnHeaderIncluded

private boolean isColumnHeaderIncluded


isDynamicAdjustment

private boolean isDynamicAdjustment


isOnlyAdjustLarger

private boolean isOnlyAdjustLarger


spacing

private int spacing


table

private JTable table


 
Constructor Detail

TableColumnAdjuster

public TableColumnAdjuster(JTable table)


TableColumnAdjuster

public TableColumnAdjuster(JTable table, int spacing)


 
Method Detail

adjustColumn

public void adjustColumn(int column)


adjustColumns

public void adjustColumns()


getCellDataWidth

private int getCellDataWidth(int row, int column)


getColumnDataWidth

private int getColumnDataWidth(int column)


getColumnHeaderWidth

private int getColumnHeaderWidth(int column)


installActions

private void installActions()


installColumnAction

private void installColumnAction(boolean isSelectedColumn, boolean isAdjust, String key, String keyStroke)


installToggleAction

private void installToggleAction(boolean isToggleDynamic, boolean isToggleLarger, String key, String keyStroke)


propertyChange

public void propertyChange(PropertyChangeEvent e)


restoreColumn

private void restoreColumn(int column)


restoreColumns

public void restoreColumns()


setColumnDataIncluded

public void setColumnDataIncluded(boolean isColumnDataIncluded)


setColumnHeaderIncluded

public void setColumnHeaderIncluded(boolean isColumnHeaderIncluded)


setDynamicAdjustment

public void setDynamicAdjustment(boolean isDynamicAdjustment)


setOnlyAdjustLarger

public void setOnlyAdjustLarger(boolean isOnlyAdjustLarger)


tableChanged

public void tableChanged(TableModelEvent e)


updateTableColumn

private void updateTableColumn(int column, int width)


 

Groovy Documentation