javax.swing.table

Class JTableHeader

Implemented Interfaces:
Accessible, EventListener, ImageObserver, MenuContainer, Serializable, TableColumnModelListener

public class JTableHeader
extends JComponent
implements TableColumnModelListener, Accessible

See Also:
Serialized Form

Nested Class Summary

protected class
JTableHeader.AccessibleJTableHeader

Nested classes/interfaces inherited from class javax.swing.JComponent

JComponent.AccessibleJComponent

Nested classes/interfaces inherited from class java.awt.Container

Container.AccessibleAWTContainer

Nested classes/interfaces inherited from class java.awt.Component

Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy

Field Summary

protected TableColumnModel
columnModel
The columnModel property.
protected TableColumn
draggedColumn
The draggedColumn property.
protected int
draggedDistance
The draggedDistance property.
protected boolean
reorderingAllowed
The reorderingAllowed property.
protected boolean
resizingAllowed
The resizingAllowed property.
protected TableColumn
resizingColumn
The resizingColumn property.
protected JTable
table
The table property.
protected boolean
updateTableInRealTime
The updateTableInRealTime property.

Fields inherited from class javax.swing.JComponent

TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW, accessibleContext, listenerList, ui

Fields inherited from class java.awt.Component

BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT

Fields inherited from interface java.awt.image.ImageObserver

ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH

Constructor Summary

JTableHeader()
Creates a new default instance.
JTableHeader(TableColumnModel cm)
Creates a new header.

Method Summary

void
columnAdded(TableColumnModelEvent event)
Receives notification when a column is added to the column model.
int
columnAtPoint(Point point)
Returns the index of the column at the specified point.
void
columnMarginChanged(ChangeEvent event)
Receives notification when a column margin changes in the column model.
void
columnMoved(TableColumnModelEvent event)
Receives notification when a column is moved within the column model.
void
columnRemoved(TableColumnModelEvent event)
Receives notification when a column is removed from the column model.
void
columnSelectionChanged(ListSelectionEvent event)
Receives notification when the column selection has changed.
protected TableColumnModel
createDefaultColumnModel()
Creates a default table column model.
protected TableCellRenderer
createDefaultRenderer()
Creates a default renderer.
AccessibleContext
getAccessibleContext()
Get the value of the JTableHeader property.
TableColumnModel
getColumnModel()
Get the value of the columnModel property.
TableCellRenderer
getDefaultRenderer()
Returns the default table cell renderer.
TableColumn
getDraggedColumn()
Get the value of the draggedColumn property.
int
getDraggedDistance()
Get the value of the draggedDistance property.
Rectangle
getHeaderRect(int column)
boolean
getReorderingAllowed()
Get the value of the reorderingAllowed property.
boolean
getResizingAllowed()
Get the value of the resizingAllowed property.
TableColumn
getResizingColumn()
Get the value of the resizingColumn property.
JTable
getTable()
Get the value of the table property.
TableHeaderUI
getUI()
String
getUIClassID()
Get the value of the UIClassID property.
boolean
getUpdateTableInRealTime()
Get the value of the updateTableInRealTime property.
protected void
initializeLocalVars()
Initializes the fields and properties of this class with default values.
boolean
isOpaque()
Get the value of the JTableHeader property.
protected String
paramString()
Return a string representation for this component, for use in debugging.
void
resizeAndRepaint()
Validates the layout of this table header and repaints it.
void
setColumnModel(TableColumnModel c)
Set the value of the columnModel property.
void
setDefaultRenderer(TableCellRenderer cellRenderer)
Sets the default table cell renderer.
void
setDraggedColumn(TableColumn d)
Set the value of the draggedColumn property.
void
setDraggedDistance(int d)
Set the value of the draggedDistance property.
void
setOpaque(boolean o)
Set the value of the JTableHeader property.
void
setReorderingAllowed(boolean r)
Set the value of the reorderingAllowed property.
void
setResizingAllowed(boolean r)
Set the value of the resizingAllowed property.
void
setResizingColumn(TableColumn r)
Set the value of the resizingColumn property.
void
setTable(JTable t)
Set the value of the table property.
void
setUI(TableHeaderUI u)
void
setUpdateTableInRealTime(boolean u)
Set the value of the updateTableInRealTime property.
void
updateUI()
This method should be overridden in subclasses.

Methods inherited from class javax.swing.JComponent

addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI

Methods inherited from class java.awt.Container

add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, swapComponents, transferFocusDownCycle, update, validate, validateTree

Methods inherited from class java.awt.Component

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, 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, getListeners, 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, isOpaque, 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, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate

Methods inherited from class java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

columnModel

protected TableColumnModel columnModel
The columnModel property.


draggedColumn

protected TableColumn draggedColumn
The draggedColumn property.


draggedDistance

protected int draggedDistance
The draggedDistance property.


reorderingAllowed

protected boolean reorderingAllowed
The reorderingAllowed property.


resizingAllowed

protected boolean resizingAllowed
The resizingAllowed property.


resizingColumn

protected TableColumn resizingColumn
The resizingColumn property.


table

protected JTable table
The table property.


updateTableInRealTime

protected boolean updateTableInRealTime
The updateTableInRealTime property.

Constructor Details

JTableHeader

public JTableHeader()
Creates a new default instance.


JTableHeader

public JTableHeader(TableColumnModel cm)
Creates a new header. If cm is null, a new table column model is created by calling createDefaultColumnModel().

Parameters:
cm - the table column model (null permitted).

Method Details

columnAdded

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


columnAtPoint

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.


columnMarginChanged

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


columnMoved

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


columnRemoved

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


columnSelectionChanged

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


createDefaultColumnModel

protected TableColumnModel createDefaultColumnModel()
Creates a default table column model.

Returns:
A default table column model.


createDefaultRenderer

protected TableCellRenderer createDefaultRenderer()
Creates a default renderer.

Returns:
A default renderer.


getAccessibleContext

public AccessibleContext getAccessibleContext()
Get the value of the JTableHeader property.
Specified by:
getAccessibleContext in interface Accessible
Overrides:
getAccessibleContext in interface JComponent

Returns:
The current value of the property


getColumnModel

public TableColumnModel getColumnModel()
Get the value of the columnModel property.

Returns:
The current value of the property


getDefaultRenderer

public TableCellRenderer getDefaultRenderer()
Returns the default table cell renderer.

Returns:
The default table cell renderer.


getDraggedColumn

public TableColumn getDraggedColumn()
Get the value of the draggedColumn property.

Returns:
The current value of the property


getDraggedDistance

public int getDraggedDistance()
Get the value of the draggedDistance property.

Returns:
The current value of the property


getHeaderRect

public Rectangle getHeaderRect(int column)


getReorderingAllowed

public boolean getReorderingAllowed()
Get the value of the reorderingAllowed property.

Returns:
The current value of the property


getResizingAllowed

public boolean getResizingAllowed()
Get the value of the resizingAllowed property.

Returns:
The current value of the property


getResizingColumn

public TableColumn getResizingColumn()
Get the value of the resizingColumn property.

Returns:
The current value of the property


getTable

public JTable getTable()
Get the value of the table property.

Returns:
The current value of the property


getUI

public TableHeaderUI getUI()


getUIClassID

public String getUIClassID()
Get the value of the UIClassID property. This property should be a key in the UIDefaults table managed by UIManager, the value of which is the name of a class to load for the component's JComponent.ui property.
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"

See Also:
JComponent.setUI(ComponentUI), JComponent.updateUI()


getUpdateTableInRealTime

public boolean getUpdateTableInRealTime()
Get the value of the updateTableInRealTime property.

Returns:
The current value of the property


initializeLocalVars

protected void initializeLocalVars()
Initializes the fields and properties of this class with default values. This is called by the constructors.


isOpaque

public boolean isOpaque()
Get the value of the JTableHeader property.
Overrides:
isOpaque in interface JComponent

Returns:
The current value of the property


paramString

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.


resizeAndRepaint

public void resizeAndRepaint()
Validates the layout of this table header and repaints it. This is equivalent to revalidate() followed by repaint().


setColumnModel

public void setColumnModel(TableColumnModel c)
Set the value of the columnModel property.

Parameters:
c - The new value of the property


setDefaultRenderer

public void setDefaultRenderer(TableCellRenderer cellRenderer)
Sets the default table cell renderer.

Parameters:
cellRenderer - the renderer.


setDraggedColumn

public void setDraggedColumn(TableColumn d)
Set the value of the draggedColumn property.

Parameters:
d - The new value of the property


setDraggedDistance

public void setDraggedDistance(int d)
Set the value of the draggedDistance property.

Parameters:
d - The new value of the property


setOpaque

public void setOpaque(boolean o)
Set the value of the JTableHeader property.
Overrides:
setOpaque in interface JComponent

Parameters:
o - The new value of the property


setReorderingAllowed

public void setReorderingAllowed(boolean r)
Set the value of the reorderingAllowed property.

Parameters:
r - The new value of the property


setResizingAllowed

public void setResizingAllowed(boolean r)
Set the value of the resizingAllowed property.

Parameters:
r - The new value of the property


setResizingColumn

public void setResizingColumn(TableColumn r)
Set the value of the resizingColumn property.

Parameters:
r - The new value of the property


setTable

public void setTable(JTable t)
Set the value of the table property.

Parameters:
t - The new value of the property


setUI

public void setUI(TableHeaderUI u)


setUpdateTableInRealTime

public void setUpdateTableInRealTime(boolean u)
Set the value of the updateTableInRealTime property.

Parameters:
u - The new value of the property


updateUI

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 from JComponent.getUIClassID()) from the UIManager, and calls JComponent.setUI(ComponentUI) with the new delegate.
Overrides:
updateUI in interface JComponent


JTableHeader.java -- Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.