All Packages  Class Hierarchy  This Package  Previous  Next  Index

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.

See Also:
JTable

Variable Index

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

Constructor Index

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

Method Index

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

Variables

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

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

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

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

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

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

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

Constructors

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

See Also:
createDefaultColumnModel
 o 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

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

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

 o 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
 o 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
 o 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
 o 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
 o getDraggedColumn
 public int getDraggedColumn()
Returns the index of the dragged column, if and only if a drag is in process.

Returns:
the index of the dragged column, if and only if a drag is in process, otherwise returns -1
See Also:
getDraggedDistance
 o 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
 o getResizingColumn
 public int getResizingColumn()
Returns the index of the resizing column. If no column is being resized this method returns -1.

Returns:
the index of the resizing column
 o 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
 o 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
 o 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
 o 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
 o getUI
 public TableHeaderUI getUI()
 o setUI
 public void setUI(TableHeaderUI ui)
 o updateUI
 public void updateUI()
Notification from the UIFactory that the L&F has changed.

Overrides:
updateUI in class JComponent
 o getUIClassID
 public String getUIClassID()
Returns:
"TableHeaderUI"
Overrides:
getUIClassID in class JComponent
See Also:
getUIClassID, getUI
 o 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
 o 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
 o columnAdded
 public void columnAdded(TableColumnModelEvent e)
 o columnRemoved
 public void columnRemoved(TableColumnModelEvent e)
 o columnMoved
 public void columnMoved(TableColumnModelEvent e)
 o columnMarginChanged
 public void columnMarginChanged(ChangeEvent e)
 o columnSelectionChanged
 public void columnSelectionChanged(ListSelectionEvent e)
 o 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
 o initializeLocalVars
 protected void initializeLocalVars()
 o 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.

 o setDraggedColumn
 public void setDraggedColumn(int columnIndex)
Sets the header's draggedColumn to columnIndex

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

 o setResizingColumn
 public void setResizingColumn(int columnIndex)
Sets the header's resizingColumn to columnIndex

 o getAccessibleRole
 public AccessibleRole getAccessibleRole()
Get the role of this object.

Returns:
an instance of AccessibleRole describing the role of the object
Overrides:
getAccessibleRole in class JComponent
See Also:
AccessibleRole

All Packages  Class Hierarchy  This Package  Previous  Next  Index