com.sciapp.table
Class TableAssistant

java.lang.Object
  extended by com.sciapp.table.TableAssistant

public class TableAssistant
extends Object

TableAssistant is a class that provides additional functions to a JTable. More specifically:

1) It automatically resizes the column of a table to the greatest preferred width of all cells under that column, when the column is double-clicked on its border.

2) Provides a popup through which the columns of the table can be dynamically added/removed. The popup is shown upon right-clicking on the table header.


Constructor Summary
TableAssistant(JTable table)
          Constructs a TableAssistant having table as the JTable on which this object acts.
 
Method Summary
 void deselect(int modelIndex)
          Unchecks the column with model index modelIndex from the column popup.
 boolean getShowPopup()
          Returns true if the column popup is to be shown.
 void register(TableColumnModel tcm)
          The component registers itself to the listener list of tcm.
 void select(int modelIndex)
          Checks the column with model index modelIndex from the column popup.
 void setHeader(JTableHeader newTableHeader)
          Associates newTableHeader with this instance of TableAssistant.
 void setShowPopup(boolean showPopup)
          Sets a flag that is true if the column popup is to be shown.
 void unregister(TableColumnModel tcm)
          The component unregisters itself from the listener list of tcm.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableAssistant

public TableAssistant(JTable table)
Constructs a TableAssistant having table as the JTable on which this object acts.

Parameters:
table - the table
Method Detail

deselect

public void deselect(int modelIndex)
Unchecks the column with model index modelIndex from the column popup.

Parameters:
modelIndex - the model index of the table's column

getShowPopup

public boolean getShowPopup()
Returns true if the column popup is to be shown.

Returns:
the show popup flag

register

public void register(TableColumnModel tcm)
The component registers itself to the listener list of tcm.

Parameters:
tcm - the TableColumnModel

select

public void select(int modelIndex)
Checks the column with model index modelIndex from the column popup.

Parameters:
modelIndex - the model index of the table's column

setHeader

public void setHeader(JTableHeader newTableHeader)
Associates newTableHeader with this instance of TableAssistant.

Parameters:
newTableHeader - the JTableHeader to associate with this TableAssistant.

setShowPopup

public void setShowPopup(boolean showPopup)
Sets a flag that is true if the column popup is to be shown.

Parameters:
showPopup - the show popup value to set

unregister

public void unregister(TableColumnModel tcm)
The component unregisters itself from the listener list of tcm.

Parameters:
tcm - the TableColumnModel