Where Am I? Class Hierarchy (JFC) All Classes (JFC)

Class com.sun.java.swing.table.JTableHeader

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.sun.java.swing.table.JTableHeader

public class JTableHeader
extends JComponent
implements TableColumnModelListener, Accessible

This is the column header part of a JTable. I allow the user to change column widths and column ordering. I share the same TableColumnModel with a JTable.

Warning: serialized objects of this class will not be compatible with future swing releases. The current serialization support is appropriate for short term storage or RMI between Swing1.0 applications. It will not be possible to load serialized Swing1.0 objects with future releases of Swing. The JDK1.2 release of Swing will be the compatibility baseline for the serialized form of Swing objects.

See Also:
JTable

Variable Index

columnModel
The TableColumnModel of the table header
draggedColumn
The index of the column being dragged.
draggedDistance
The distance from its original position the column has been dragged
reorderingAllowed
Reordering of columns are allowed by the user
resizingAllowed
Resizing of columns are allowed by the user
resizingColumn
The index of the column being resized.
table
updateTableInRealTime
If this flag is true, then the header will repaint the table as a column is dragged or resized.

Constructor Index

JTableHeader()
Constructs a JTableHeader with a default TableColumnModel
JTableHeader(TableColumnModel)
Constructs a JTableHeader which is initialized with cm as the column model.

Method Index

columnAdded(TableColumnModelEvent)
columnAtPoint(Point)
Returns the index of the column that point lies in, or -1 if it lies outside the receiver's bounds.
columnMarginChanged(ChangeEvent)
columnMoved(TableColumnModelEvent)
columnRemoved(TableColumnModelEvent)
columnSelectionChanged(ListSelectionEvent)
createDefaultColumnModel()
Returns the default column model object which is a DefaultTableColumnModel.
getAccessibleContext()
Get the AccessibleContext associated with this JComponent
getColumnModel()
Returns the TableColumnModel that contains all column inforamtion of this table header.
getDraggedColumn()
Returns the the dragged column, if and only if a drag is in process.
getDraggedDistance()
Returns the column's horizontal distance from its original position, if and only if a drag is in process.
getHeaderRect(int)
Returns the rectangle containing the header tile at columnIndex.
getReorderingAllowed()
Returns true if the receiver allows the user to rearrange columns by dragging their headers, false otherwise.
getResizingAllowed()
Returns true if the receiver allows the user to resize columns by dragging between their headers, false otherwise.
getResizingColumn()
Returns the resizing column.
getTable()
Returns the header's partner table
getToolTipText(MouseEvent)
Overriding to allow renderer's tips to be used if it has text set.
getUI()
getUIClassID()
getUpdateTableInRealTime()
Returns true if the receiver updates the body of the table view in real time when a column is resized or dragged.
initializeLocalVars()
isOpaque()
Returns true if this component is completely opaque.
resizeAndRepaint()
Properly sizes the receiver and its header view, and marks it as needing display.
setColumnModel(TableColumnModel)
Sets the column model for this table to newModel and registers with for listner notifications from the new column model.
setDraggedColumn(TableColumn)
Sets the header's draggedColumn to aColumn
setDraggedDistance(int)
Sets the header's draggedDistance to distance
setReorderingAllowed(boolean)
Sets whether the user can drag column headers to reorder columns.
setResizingAllowed(boolean)
Sets whether the user can resize columns by dragging between headers.
setResizingColumn(TableColumn)
Sets the header's resizingColumn to aColumn
setTable(JTable)
Sets the header's partner table to aTable
setUI(TableHeaderUI)
setUpdateTableInRealTime(boolean)
Sets whether the body of the table updates in real time when a column is resized or dragged.
updateUI()
Resets the UI property to a value from the current look and feel.

Variables

table
 protected JTable table
columnModel
 protected TableColumnModel columnModel
The TableColumnModel of the table header

reorderingAllowed
 protected boolean reorderingAllowed
Reordering of columns are allowed by the user

resizingAllowed
 protected boolean resizingAllowed
Resizing of columns are allowed by the user

updateTableInRealTime
 protected boolean updateTableInRealTime
If this flag is true, then the header will repaint the table as a column is dragged or resized.

resizingColumn
 protected transient TableColumn resizingColumn
The index of the column being resized. 0 if not resizing

draggedColumn
 protected transient TableColumn draggedColumn
The index of the column being dragged. 0 if not dragging

draggedDistance
 protected transient int draggedDistance
The distance from its original position the column has been dragged


Constructors

JTableHeader
 public JTableHeader()
Constructs a JTableHeader with a default TableColumnModel

See Also:
createDefaultColumnModel
JTableHeader
 public JTableHeader(TableColumnModel cm)
Constructs a JTableHeader which is initialized with cm as the column model. If cm is null this method will initialize the table header with a default TableColumnModel.

Parameters:
cm - The column model for the table
See Also:
createDefaultColumnModel

Methods

setTable
 public void setTable(JTable aTable)
Sets the header's partner table to aTable

getTable
 public JTable getTable()
Returns the header's partner table

setReorderingAllowed
 public void setReorderingAllowed(boolean b)
Sets whether the user can drag column headers to reorder columns.

Parameters:
flag - true if the table view should allow reordering
See Also:
getReorderingAllowed
getReorderingAllowed
 public boolean getReorderingAllowed()
Returns true if the receiver allows the user to rearrange columns by dragging their headers, false otherwise. The default is true. You can rearrange columns programmatically regardless of this setting.

Returns:
true if the receiver allows the user to rearrange columns by dragging their headers, false otherwise
See Also:
setReorderingAllowed
setResizingAllowed
 public void setResizingAllowed(boolean b)
Sets whether the user can resize columns by dragging between headers.

Parameters:
flag - true if table view should allow resizing
See Also:
getResizingAllowed
getResizingAllowed
 public boolean getResizingAllowed()
Returns true if the receiver allows the user to resize columns by dragging between their headers, false otherwise. The default is true. You can resize columns programmatically regardless of this setting.

Returns:
true if the receiver allows the user to resize columns by dragging between their headers, false otherwise.
See Also:
setResizingAllowed
getDraggedColumn
 public TableColumn getDraggedColumn()
Returns the the dragged column, if and only if a drag is in process.

Returns:
the the dragged column, if and only if a drag is in process, otherwise returns null.
See Also:
getDraggedDistance
getDraggedDistance
 public int getDraggedDistance()
Returns the column's horizontal distance from its original position, if and only if a drag is in process. Otherwise, the the return value is meaningless.

Returns:
the column's horizontal distance from its original position, if and only if a drag is in process
See Also:
getDraggedColumn
getResizingColumn
 public TableColumn getResizingColumn()
Returns the resizing column. If no column is being resized this method returns null.

Returns:
the resizing column
setUpdateTableInRealTime
 public void setUpdateTableInRealTime(boolean flag)
Sets whether the body of the table updates in real time when a column is resized or dragged.

Parameters:
flag - true if tableView should update the body of the table in real time
See Also:
getUpdateTableInRealTime
getUpdateTableInRealTime
 public boolean getUpdateTableInRealTime()
Returns true if the receiver updates the body of the table view in real time when a column is resized or dragged. User can set this flag to false to speed up the table's response to user resize or drag actions. The default is true.

Returns:
true if the table updates in real time
See Also:
setUpdateTableInRealTime
columnAtPoint
 public int columnAtPoint(Point point)
Returns the index of the column that point lies in, or -1 if it lies outside the receiver's bounds.

Returns:
the index of the column that point lies in, or -1 if it lies outside the receiver's bounds
getHeaderRect
 public Rectangle getHeaderRect(int columnIndex)
Returns the rectangle containing the header tile at columnIndex.

Returns:
the rectangle containing the header tile at columnIndex
Throws: IllegalArgumentException
If columnIndex is out of range
getToolTipText
 public String getToolTipText(MouseEvent event)
Overriding to allow renderer's tips to be used if it has text set.

Overrides:
getToolTipText in class JComponent
getUI
 public TableHeaderUI getUI()
setUI
 public void setUI(TableHeaderUI ui)
updateUI
 public void updateUI()
Resets the UI property to a value from the current look and feel.

Overrides:
updateUI in class JComponent
getUIClassID
 public String getUIClassID()
Returns:
"TableHeaderUI"
Overrides:
getUIClassID in class JComponent
See Also:
getUIClassID, getUI
setColumnModel
 public void setColumnModel(TableColumnModel newModel)
Sets the column model for this table to newModel and registers with for listner notifications from the new column model.

Parameters:
newModel - the new data source for this table
Throws: IllegalArgumentException
if newModel is null
See Also:
getColumnModel
getColumnModel
 public TableColumnModel getColumnModel()
Returns the TableColumnModel that contains all column inforamtion of this table header.

Returns:
the object that provides the column state of the table
See Also:
setColumnModel
isOpaque
 public boolean isOpaque()
Returns true if this component is completely opaque.

Overrides:
isOpaque in class JComponent
columnAdded
 public void columnAdded(TableColumnModelEvent e)
columnRemoved
 public void columnRemoved(TableColumnModelEvent e)
columnMoved
 public void columnMoved(TableColumnModelEvent e)
columnMarginChanged
 public void columnMarginChanged(ChangeEvent e)
columnSelectionChanged
 public void columnSelectionChanged(ListSelectionEvent e)
createDefaultColumnModel
 protected TableColumnModel createDefaultColumnModel()
Returns the default column model object which is a DefaultTableColumnModel. Subclass can override this method to return a different column model object

Returns:
the default column model object
initializeLocalVars
 protected void initializeLocalVars()
resizeAndRepaint
 public void resizeAndRepaint()
Properly sizes the receiver and its header view, and marks it as needing display. Also resets cursor rectangles for the header view and line scroll amounts for the JScrollPane.

setDraggedColumn
 public void setDraggedColumn(TableColumn aColumn)
Sets the header's draggedColumn to aColumn

setDraggedDistance
 public void setDraggedDistance(int distance)
Sets the header's draggedDistance to distance

setResizingColumn
 public void setResizingColumn(TableColumn aColumn)
Sets the header's resizingColumn to aColumn

getAccessibleContext
 public AccessibleContext getAccessibleContext()
Get the AccessibleContext associated with this JComponent

Returns:
the AccessibleContext of this JComponent
Overrides:
getAccessibleContext in class JComponent

Where Am I? Class Hierarchy (JFC) All Classes (JFC)