hold(int columnModelIndex)
"Holds" the given index using the default orientation.
void
hold(int columnModelIndex,
int orientation)
"Holds" the given index using the orientation specified.
protected void
initializeLocalVars()
Initializes the local variables and properties with default values.
boolean
isHeightSet()
Returns true if the height of the header has been set, false otherwise.
boolean
isHeld(int columnModelIndex)
Returns true if the given modelIndex is held for any orientation,
false otherwise.
boolean
isHeld(int columnModelIndex,
int orientation)
Returns true if the given modelIndex is held for the given
orientation, false otherwise.
boolean
isHoldingAllowed(int orientation)
Returns true if holding for a given orientation is allowed or false otherwise.
boolean
isHoldingEnabled()
Returns true is holding is enabled, should return false if holding is not allowed.
void
paintComponent(java.awt.Graphics g)
Overrode this method as the clipBounds needs to be modified on the Graphics due to held columns,
if nothing is currently being held, the clipBounds will be left untouched.
printComponent(java.awt.Graphics g)
Overrode this method so that the clipbounds will not be modified to accomate the held column
when printing as the clipbounds should already be set to the correct size.
void
release(int columnModelIndex)
Releases the given modelIndex from being held, so it will
return to its original place in the view.
void
releaseAll()
Releases all held indices and returns them to their previous location.
void
setCellsToSizeCount(int newCount)
Specifies the number of cells to measure when calculating the width
of the column.
Constructs a ColumnHeader which is initialized with
model as the Column model. If model is
null this method will initialize the table header
with a default TableColumnModel.
Parameters:
model - the Column model for the table
See Also:
JTableHeader.createDefaultColumnModel()
Method Detail
isHeightSet
public boolean isHeightSet()
Returns true if the height of the header has been set, false otherwise.
Is used to determine if the column header should size itself based on its
preferred size of its labels or not.
the index of the column that point lies in, or -1 if it
lies out of bounds
columnAtPoint
public int columnAtPoint(java.awt.Point point,
boolean accountForHolds)
Returns the index of the column that point lies in, or -1 if it
lies out of bounds.
Parameters:
accountForHolds - if false and the point is over a held column, this method will
return the column index for the column beneath the held column. If true, this will return the
index of the column the point is on, taking into account the held columns.
Returns:
the index of the column that point lies in, or -1 if it
lies out of bounds
Returns the rectangle containing the header tile at row.
When the column parameter is out of bounds this method uses the
same conventions as the TableView method getCellRect.
If the column header is placed in a JScrollPane the
this will return the view position of the JViewport
that contains the column header.
Returns:
a point the represents the region of the column header that is currently
scrolled into view, the point will be the upper left corner of the column header that is
currently in view
Prepares the renderer by retrieving the column label and selection state
of the column at column.
Note:
Throughout the tableview package, the internal implementations always
use this method to prepare renderers so that this default behavior
can be safely overridden by a subclass.
Parameters:
renderer - the TableCellRenderer to prepare for the given column
column - the row index of the column to render, where 0 is the first column
initializeLocalVars
protected void initializeLocalVars()
Initializes the local variables and properties with default values.
Used by the constructor methods.
Specifies the number of cells to measure when calculating the width
of the column. A value of zero will cause only the column's
label to be measured, while a negative value will measure all cells.
Calculating the width of all the cells in a column could be time consuming so
be careful when setting a negative value or a large value.
The default value is 25.
Parameters:
newCount - the number of cells to measure to determine the width of the columns,
a negative value equates to calculating the width of all cells.
Returns the number of cells in a column to measure when calculating the
width of the column. A value of zero will cause only the column's
label to be measured, while a negative value will measure all cells in the column.
The default value is 25.
Returns:
the number of cells to measure the width of to determine the height of a column
Sizes the given column to the width needed based on it's label and data. A few conditions
have to be met for this to actually resize the column:
the table must have the autoResizeMode turned off
resizing on the header must be allowed
resizing on the given column must be allowed
This method calls calculatePreferredWidthForColumn(int) to determine the width for the given column.
The width the column actually receive may not be the same value that is returned from the
calculatePreferredWidthForColumn(int) as a minimum or maximum size may already be set on the
TableColumn.
Parameters:
column - the viewer index of the column to remeasure to fit
Sizes all the columns to the width needed based on their label and data. A few conditions
have to be met for this to actually resize the columns:
the table must have the autoResizeMode turned off
resizing on the header must be allowed
resizing on each table column must be allowed
This method calls calculatePreferredWidthForColumns(int[]) to determine the width for each column.
The width the columns actually receive may not be the same value that is returned from the
calculatePreferredWidthForColumns(int[]) as a minimum or maximum size may already be set on the
TableColumn.
public int[] calculatePreferredWidthForColumns(int[] columns)
Calculates the preferred width for the given column based on it's label and data.
The method uses the value from getCellToSizeCount() to determine the number of
cells to measure to determine the column width. This is compared with the preferred width of
the column label and the larger size is returned for the column. This width may not be the
best fit as the value returned from getCellToSizeCount() may be too small so that
too few of cells were measured to determine the column width.
Parameters:
columns - an array of integers of the viewer indexes of columns requesting their size
calculated
Returns:
an array on integers that indicate the size for each column, or an empty array if
no columns were requested or allowed to be resized
protected int getPreferredHeaderWidthForColumn(int column)
calculatePreferredWidthForColumn
public int calculatePreferredWidthForColumn(int column)
Calculates the preferred width for the given column based on it's label and data.
The method uses the value from getCellToSizeCount() to determine the number of
cells to measure to determine the column width. This is compared with the preferred width of
the column label and the larger size is returned for the column. This width may not be the
best fit as the value returned from getCellToSizeCount() may be too small so that
too few of cells were measured to determine the column width.
Parameters:
column - the viewer index of the column to measure
Overrode this method as the clipBounds needs to be modified on the Graphics due to held columns,
if nothing is currently being held, the clipBounds will be left untouched.
Overrode this method so that the clipbounds will not be modified to accomate the held column
when printing as the clipbounds should already be set to the correct size.
Returns a list of the indices that are being held. This list will include
all the indices for all the orientations. Modifications to this list will
not be reflected in the held list, this list is a duplicate.
Returns a list of the indices that are being held for the given orientation.
Modifications to this list will be reflected in the held list as this is the
true list.
"Holds" the given index using the default orientation.
For example, on a table, the default held column location would be on the left side and
for a row would be at the top. A held index is one that has been made non-scrollable and is thus
always, space permitting, displayed; i.e. it is never scrolled out
of view.
The order in which the indices are held controls the order in which
they are displayed.
"Holds" the given index using the orientation specified.
For example, on a table, a column could be held on the left or right and a row could
be held on the top or bottom. A held index is one that has been made non-scrollable
and is thus always, space permitting, displayed; i.e. it is never scrolled out
of view.
The order in which the indices are held controls the order in which
they are displayed.