Methods Summary |
---|
public void | columnAdded(javax.swing.event.TableColumnModelEvent e)Invoked when a column is added to the table column model.
Application code will not use these methods explicitly, they
are used internally by JTable . resizeAndRepaint();
|
public int | columnAtPoint(java.awt.Point point)Returns the index of the column that point lies in, or -1 if it
lies out of bounds.
int x = point.x;
if (!getComponentOrientation().isLeftToRight()) {
x = getWidthInRightToLeft() - x;
}
return getColumnModel().getColumnIndexAtX(x);
|
public void | columnMarginChanged(javax.swing.event.ChangeEvent e)Invoked when a column is moved due to a margin change.
Application code will not use these methods explicitly, they
are used internally by JTable . resizeAndRepaint();
|
public void | columnMoved(javax.swing.event.TableColumnModelEvent e)Invoked when a column is repositioned.
Application code will not use these methods explicitly, they
are used internally by JTable . repaint();
|
public void | columnRemoved(javax.swing.event.TableColumnModelEvent e)Invoked when a column is removed from the table column model.
Application code will not use these methods explicitly, they
are used internally by JTable . resizeAndRepaint();
|
public void | columnSelectionChanged(javax.swing.event.ListSelectionEvent e)Invoked when the selection model of the TableColumnModel
is changed. This method currently has no effect (the header is not
redrawn).
Application code will not use these methods explicitly, they
are used internally by JTable .
|
protected javax.swing.table.TableColumnModel | createDefaultColumnModel()Returns the default column model object which is
a DefaultTableColumnModel . A subclass can override this
method to return a different column model object
return new DefaultTableColumnModel();
|
protected javax.swing.table.TableCellRenderer | createDefaultRenderer()Returns a default renderer to be used when no header renderer
is defined by a TableColumn .
DefaultTableCellRenderer label = new UIResourceTableCellRenderer();
label.setHorizontalAlignment(JLabel.CENTER);
return label;
|
public javax.accessibility.AccessibleContext | getAccessibleContext()Gets the AccessibleContext associated with this JTableHeader.
For JTableHeaders, the AccessibleContext takes the form of an
AccessibleJTableHeader.
A new AccessibleJTableHeader instance is created if necessary.
if (accessibleContext == null) {
accessibleContext = new AccessibleJTableHeader();
}
return accessibleContext;
|
public javax.swing.table.TableColumnModel | getColumnModel()Returns the TableColumnModel that contains all column information
of this table header.
return columnModel;
|
public javax.swing.table.TableCellRenderer | getDefaultRenderer()Returns the default renderer used when no headerRenderer
is defined by a TableColumn .
return defaultRenderer;
|
public javax.swing.table.TableColumn | getDraggedColumn()Returns the the dragged column, if and only if, a drag is in
process, otherwise returns null .
return draggedColumn;
|
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.
return draggedDistance;
|
public java.awt.Rectangle | getHeaderRect(int column)Returns the rectangle containing the header tile at column .
When the column parameter is out of bounds this method uses the
same conventions as the JTable method getCellRect .
Rectangle r = new Rectangle();
TableColumnModel cm = getColumnModel();
r.height = getHeight();
if (column < 0) {
// x = width = 0;
if( !getComponentOrientation().isLeftToRight() ) {
r.x = getWidthInRightToLeft();
}
}
else if (column >= cm.getColumnCount()) {
if( getComponentOrientation().isLeftToRight() ) {
r.x = getWidth();
}
}
else {
for(int i = 0; i < column; i++) {
r.x += cm.getColumn(i).getWidth();
}
if( !getComponentOrientation().isLeftToRight() ) {
r.x = getWidthInRightToLeft() - r.x - cm.getColumn(column).getWidth();
}
r.width = cm.getColumn(column).getWidth();
}
return r;
|
public boolean | getReorderingAllowed()Returns true if the user is allowed to rearrange columns by
dragging their headers, false otherwise. The default is true. You can
rearrange columns programmatically regardless of this setting.
return reorderingAllowed;
|
public boolean | getResizingAllowed()Returns true if the user is allowed to resize columns by dragging
between their headers, false otherwise. The default is true. You can
resize columns programmatically regardless of this setting.
return resizingAllowed;
|
public javax.swing.table.TableColumn | getResizingColumn()Returns the resizing column. If no column is being
resized this method returns null .
return resizingColumn;
|
public javax.swing.JTable | getTable()Returns the table associated with this header.
return table;
|
public java.lang.String | getToolTipText(java.awt.event.MouseEvent event)Allows the renderer's tips to be used if there is text set.
String tip = null;
Point p = event.getPoint();
int column;
// Locate the renderer under the event location
if ((column = columnAtPoint(p)) != -1) {
TableColumn aColumn = columnModel.getColumn(column);
TableCellRenderer renderer = aColumn.getHeaderRenderer();
if (renderer == null) {
renderer = defaultRenderer;
}
Component component = renderer.getTableCellRendererComponent(
getTable(), aColumn.getHeaderValue(), false, false,
-1, column);
// Now have to see if the component is a JComponent before
// getting the tip
if (component instanceof JComponent) {
// Convert the event to the renderer's coordinate system
MouseEvent newEvent;
Rectangle cellRect = getHeaderRect(column);
p.translate(-cellRect.x, -cellRect.y);
newEvent = new MouseEvent(component, event.getID(),
event.getWhen(), event.getModifiers(),
p.x, p.y, event.getClickCount(),
event.isPopupTrigger());
tip = ((JComponent)component).getToolTipText(newEvent);
}
}
// No tip from the renderer get our own tip
if (tip == null)
tip = getToolTipText();
return tip;
|
public javax.swing.plaf.TableHeaderUI | getUI()Returns the look and feel (L&F) object that renders this component.
return (TableHeaderUI)ui;
|
public java.lang.String | getUIClassID()Returns the suffix used to construct the name of the look and feel
(L&F) class used to render this component.
return uiClassID;
|
public boolean | getUpdateTableInRealTime()Obsolete as of Java 2 platform v1.3. Real time repaints, in response to
column dragging or resizing, are now unconditional.
return updateTableInRealTime;
|
private int | getWidthInRightToLeft()
if ((table != null) &&
(table.getAutoResizeMode() != JTable.AUTO_RESIZE_OFF)) {
return table.getWidth();
}
return super.getWidth();
|
protected void | initializeLocalVars()Initializes the local variables and properties with default values.
Used by the constructor methods.
setOpaque(true);
table = null;
reorderingAllowed = true;
resizingAllowed = true;
draggedColumn = null;
draggedDistance = 0;
resizingColumn = null;
updateTableInRealTime = true;
// I'm registered to do tool tips so we can draw tips for the
// renderers
ToolTipManager toolTipManager = ToolTipManager.sharedInstance();
toolTipManager.registerComponent(this);
setDefaultRenderer(createDefaultRenderer());
|
protected java.lang.String | paramString()Returns a string representation of this JTableHeader . This method
is intended to be used only for debugging purposes, and the
content and format of the returned string may vary between
implementations. The returned string may be empty but may not
be null .
Overriding paramString to provide information about the
specific new aspects of the JFC components.
String reorderingAllowedString = (reorderingAllowed ?
"true" : "false");
String resizingAllowedString = (resizingAllowed ?
"true" : "false");
String updateTableInRealTimeString = (updateTableInRealTime ?
"true" : "false");
return super.paramString() +
",draggedDistance=" + draggedDistance +
",reorderingAllowed=" + reorderingAllowedString +
",resizingAllowed=" + resizingAllowedString +
",updateTableInRealTime=" + updateTableInRealTimeString;
|
public void | resizeAndRepaint()Sizes the header and marks it as needing display. Equivalent
to revalidate followed by repaint .
revalidate();
repaint();
|
public void | setColumnModel(javax.swing.table.TableColumnModel columnModel)Sets the column model for this table to newModel and registers
for listener notifications from the new column model.
if (columnModel == null) {
throw new IllegalArgumentException("Cannot set a null ColumnModel");
}
TableColumnModel old = this.columnModel;
if (columnModel != old) {
if (old != null) {
old.removeColumnModelListener(this);
}
this.columnModel = columnModel;
columnModel.addColumnModelListener(this);
firePropertyChange("columnModel", old, columnModel);
resizeAndRepaint();
}
|
public void | setDefaultRenderer(javax.swing.table.TableCellRenderer defaultRenderer)Sets the default renderer to be used when no headerRenderer
is defined by a TableColumn .
this.defaultRenderer = defaultRenderer;
|
public void | setDraggedColumn(javax.swing.table.TableColumn aColumn)Sets the header's draggedColumn to aColumn .
Application code will not use this method explicitly, it is used
internally by the column dragging mechanism.
draggedColumn = aColumn;
|
public void | setDraggedDistance(int distance)Sets the header's draggedDistance to distance .
draggedDistance = distance;
|
public void | setReorderingAllowed(boolean reorderingAllowed)Sets whether the user can drag column headers to reorder columns.
boolean old = this.reorderingAllowed;
this.reorderingAllowed = reorderingAllowed;
firePropertyChange("reorderingAllowed", old, reorderingAllowed);
|
public void | setResizingAllowed(boolean resizingAllowed)Sets whether the user can resize columns by dragging between headers.
boolean old = this.resizingAllowed;
this.resizingAllowed = resizingAllowed;
firePropertyChange("resizingAllowed", old, resizingAllowed);
|
public void | setResizingColumn(javax.swing.table.TableColumn aColumn)Sets the header's resizingColumn to aColumn .
Application code will not use this method explicitly, it
is used internally by the column sizing mechanism.
resizingColumn = aColumn;
|
public void | setTable(javax.swing.JTable table)Sets the table associated with this header.
JTable old = this.table;
this.table = table;
firePropertyChange("table", old, table);
|
public void | setUI(javax.swing.plaf.TableHeaderUI ui)Sets the look and feel (L&F) object that renders this component.
if (this.ui != ui) {
super.setUI(ui);
repaint();
}
|
public void | setUpdateTableInRealTime(boolean flag)Obsolete as of Java 2 platform v1.3. Real time repaints, in response to
column dragging or resizing, are now unconditional.
updateTableInRealTime = flag;
|
public void | updateUI()Notification from the UIManager that the look and feel
(L&F) has changed.
Replaces the current UI object with the latest version from the
UIManager .
setUI((TableHeaderUI)UIManager.getUI(this));
resizeAndRepaint();
invalidate();//PENDING
|
private void | writeObject(java.io.ObjectOutputStream s)See readObject and writeObject in
JComponent for more
information about serialization in Swing.
s.defaultWriteObject();
if ((ui != null) && (getUIClassID().equals(uiClassID))) {
ui.installUI(this);
}
|