java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.table.JTableHeaderprotected class protected TableColumnModel columnModel protected TableColumn draggedColumn protected int draggedDistance protected boolean reorderingAllowed protected boolean resizingAllowed protected TableColumn resizingColumn protected boolean updateTableInRealTime JTableHeader()JTableHeader(TableColumnModel cm) void columnAdded(TableColumnModelEvent event) int columnAtPoint(Point point) void columnMarginChanged(ChangeEvent event) void columnMoved(TableColumnModelEvent event) void columnRemoved(TableColumnModelEvent event) void columnSelectionChanged(ListSelectionEvent event)protected TableColumnModel createDefaultColumnModel()protected TableCellRenderer createDefaultRenderer() AccessibleContext getAccessibleContext()JComponent.accessibleContext property.
TableColumnModel getColumnModel()columnModel property.
TableCellRenderer getDefaultRenderer() TableColumn getDraggedColumn() int getDraggedDistance()draggedDistance property.
Rectangle getHeaderRect(int column) boolean getReorderingAllowed() boolean getResizingAllowed() TableColumn getResizingColumn() String getUIClassID() boolean getUpdateTableInRealTime()updateTableInRealTime property.
protected void initializeLocalVars()protected String paramString() void resizeAndRepaint() void setColumnModel(TableColumnModel c)columnModel property.
void setDefaultRenderer(TableCellRenderer cellRenderer) void setDraggedColumn(TableColumn draggingIt) void setDraggedDistance(int d)draggedDistance property.
void setReorderingAllowed(boolean allowed) void setResizingAllowed(boolean allowed) void setResizingColumn(TableColumn resizingIt) void void setUpdateTableInRealTime(boolean u)updateTableInRealTime property.
void updateUI()addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, extends EventListener> T[] getListeners, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setNextFocusableComponent, setOpaque, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, extends EventListener> T[] getListeners, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponentZOrder, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTree action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, extends EventListener> T[] getListeners, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFocusable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFocusable, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate public JTableHeader(TableColumnModel cm)
Creates a new header. Ifcmisnull, a new table column model is created by callingcreateDefaultColumnModel().
- Parameters:
cm- the table column model (nullpermitted).
public void columnAdded(TableColumnModelEvent event)
Receives notification when a column is added to the column model.
- Specified by:
- columnAdded in interface TableColumnModelListener
- Parameters:
event- the table column model event
public int columnAtPoint(Point point)
Returns the index of the column at the specified point.
- Parameters:
point- the point.
- Returns:
- The column index, or -1.
public void columnMarginChanged(ChangeEvent event)
Receives notification when a column margin changes in the column model.
- Specified by:
- columnMarginChanged in interface TableColumnModelListener
- Parameters:
event- the table column model event
public void columnMoved(TableColumnModelEvent event)
Receives notification when a column is moved within the column model.
- Specified by:
- columnMoved in interface TableColumnModelListener
- Parameters:
event- the table column model event
public void columnRemoved(TableColumnModelEvent event)
Receives notification when a column is removed from the column model.
- Specified by:
- columnRemoved in interface TableColumnModelListener
- Parameters:
event- the table column model event
public void columnSelectionChanged(ListSelectionEvent event)
Receives notification when the column selection has changed.
- Specified by:
- columnSelectionChanged in interface TableColumnModelListener
- Parameters:
event- the table column model event
protected TableColumnModel createDefaultColumnModel()
Creates a default table column model.
- Returns:
- A default table column model.
protected TableCellRenderer createDefaultRenderer()
Creates a default renderer.
- Returns:
- A default renderer.
public AccessibleContext getAccessibleContext()
Get the value of theJComponent.accessibleContextproperty.
- Specified by:
- getAccessibleContext in interface Accessible
- Overrides:
- getAccessibleContext in interface JComponent
- Returns:
- The current value of the property
public TableColumnModel getColumnModel()
Get the value of thecolumnModelproperty.
- Returns:
- The current value of the property
public TableCellRenderer getDefaultRenderer()
Returns the default table cell renderer.
- Returns:
- The default table cell renderer.
public TableColumn getDraggedColumn()
Get the column that is currently being dragged. This is used when handling the column reordering with mouse.
- Returns:
- the column being dragged, null if none.
public int getDraggedDistance()
Get the value of thedraggedDistanceproperty.
- Returns:
- The current value of the property
public Rectangle getHeaderRect(int column)
Get the rectangle, occupied by the header of the given column.
- Parameters:
column- the column, for that the header area is requested.
- Returns:
- the column header area.
public boolean getReorderingAllowed()
Check if it is possible to reorder the table columns by dragging column header with mouse. The table reordering is enabled by default, but can be disabled withsetReorderingAllowed(boolean).
- Returns:
- true if reordering is allowed, false otherwise.
public boolean getResizingAllowed()
Check if it is possible to resize the table columns by dragging the column boundary in the table header with mouse. The resizing is enabled by default, but can be disabled withsetResizingAllowed(boolean).
- Returns:
- true if resizing is allowed, false otherwise.
public TableColumn getResizingColumn()
Get the column that is currently being resized. This is used when handling the column resizing with mouse.
- Returns:
- the column being currently resized, null if none.
public JTable getTable()
Get the table, having this header.
- Returns:
- the table, having this header.
public TableHeaderUI getUI()
public String getUIClassID()
Get the value of the UIClassID property. This property should be a key in theUIDefaultstable managed byUIManager, the value of which is the name of a class to load for the component'sJComponent.uiproperty.
- Overrides:
- getUIClassID in interface JComponent
- Returns:
- A "symbolic" name which will map to a class to use for the component's UI, such as
"ComponentUI"
public boolean getUpdateTableInRealTime()
Get the value of theupdateTableInRealTimeproperty.
- Returns:
- The current value of the property
protected void initializeLocalVars()
Initializes the fields and properties of this class with default values. This is called by the constructors.
public boolean isOpaque()
Get the value of theopaqueproperty.
- Overrides:
- isOpaque in interface JComponent
- Returns:
- The current value of the property
protected String paramString()
Return a string representation for this component, for use in debugging.
- Overrides:
- paramString in interface JComponent
- Returns:
- A string describing this component.
public void resizeAndRepaint()
Validates the layout of this table header and repaints it. This is equivalent torevalidate()followed byrepaint().
public void setColumnModel(TableColumnModel c)
Set the value of thecolumnModelproperty.
- Parameters:
c- The new value of the property
public void setDefaultRenderer(TableCellRenderer cellRenderer)
Sets the default table cell renderer.
- Parameters:
cellRenderer- the renderer.
public void setDraggedColumn(TableColumn draggingIt)
Set the column that is currently being dragged. This is used when dragging the column with mouse. Setting to null will stop the dragging session immediately.
- Parameters:
draggingIt- the column being currently dragged, null if none.
public void setDraggedDistance(int d)
Set the value of thedraggedDistanceproperty.
- Parameters:
d- The new value of the property
public void setOpaque(boolean o)
Set the value of theopaqueproperty.
- Overrides:
- setOpaque in interface JComponent
- Parameters:
o- The new value of the property
public void setReorderingAllowed(boolean allowed)
Set the table ability to reorder columns by dragging column header with mouse. The table reordering is enabled by default, but can be disabled with this method.
- Parameters:
allowed- true if reordering is allowed, false otherwise.
public void setResizingAllowed(boolean allowed)
Set the table ability to resize columns by dragging the column boundary in the table header with mouse. The resizing is enabled by default, but can be disabled using this method.
- Parameters:
allowed- true if resizing is allowed, false otherwise.
public void setResizingColumn(TableColumn resizingIt)
The the column that is currently being resized. This property is used when handling table resizing with mouse. Setting to null would stop the resizing session immediately.
- Parameters:
resizingIt- the column being currently resized
public void setTable(JTable t)
Set the value of thetableproperty.
- Parameters:
t- The new value of the property
public void setUI(TableHeaderUI u)
public void setUpdateTableInRealTime(boolean u)
Set the value of theupdateTableInRealTimeproperty.
- Parameters:
u- The new value of the property
public void updateUI()
This method should be overridden in subclasses. In JComponent, the method does nothing. In subclasses, it should a UI delegate (corresponding to the symbolic name returned fromJComponent.getUIClassID()) from theUIManager, and callsJComponent.setUI(ComponentUI)with the new delegate.
- Overrides:
- updateUI in interface JComponent