Class java.awt.swing.table.JTableHeader
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.swing.JComponent
|
+----java.awt.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.
Warning: serialized objects of this class will not be compatible with
future swing releases. The current serialization support is appropriate
for short term storage or RMI between Swing1.0 applications. It will
not be possible to load serialized Swing1.0 objects with future releases
of Swing. The JDK1.2 release of Swing will be the compatibility
baseline for the serialized form of Swing objects.
- See Also:
- JTable
Constructor Summary
|
JTableHeader()
Constructs a JTableHeader with a default TableColumnModel
|
JTableHeader(TableColumnModel cm)
Constructs a JTableHeader which is initialized with
cm as the column model.
|
Methods inherited from class java.awt.swing.JComponent
|
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setBounds, setDebugGraphicsOptions, setDoubleBuffered, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update, updateUI |
Methods inherited from class java.awt.Container
|
add, add, add, add, add, addContainerListener, addImpl, addNotify, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setLayout, update, validate, validateTree |
Methods inherited from class java.awt.Component
|
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getColorModel, getComponentAt, getComponentAt, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isEnabled, isFocusTraversable, 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, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate |
Methods inherited from class java.lang.Object
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
table
protected JTable table
columnModel
protected TableColumnModel columnModel
- The TableColumnModel of the table header
reorderingAllowed
protected boolean reorderingAllowed
- Reordering of columns are allowed by the user
resizingAllowed
protected boolean resizingAllowed
- Resizing of columns are allowed by the user
updateTableInRealTime
protected boolean updateTableInRealTime
- If this flag is true, then the header will repaint the table as
a column is dragged or resized.
resizingColumn
protected transient TableColumn resizingColumn
- The index of the column being resized. 0 if not resizing
draggedColumn
protected transient TableColumn draggedColumn
- The index of the column being dragged. 0 if not dragging
draggedDistance
protected transient int draggedDistance
- The distance from its original position the column has been dragged
JTableHeader
public JTableHeader()
- Constructs a JTableHeader with a default TableColumnModel
- See Also:
- createDefaultColumnModel()
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()
setTable
public void setTable(JTable aTable)
- Sets the header's partner table to aTable
getTable
public JTable getTable()
- Returns the header's partner table
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()
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()
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()
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()
getDraggedColumn
public TableColumn getDraggedColumn()
- Returns the the dragged column, if and only if a drag is in
process.
- Returns:
- the the dragged column, if and only if a drag is in
process, otherwise returns null.
- See Also:
- getDraggedDistance()
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()
getResizingColumn
public TableColumn getResizingColumn()
- Returns the resizing column. If no column is being
resized this method returns null.
- Returns:
- the resizing column
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()
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()
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
getHeaderRect
public Rectangle getHeaderRect(int columnIndex)
- Returns the rectangle containing the header tile at columnIndex.
- Returns:
- the rectangle containing the header tile at columnIndex
- Throws:
- IllegalArgumentException - If columnIndex is out
of range
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
getUI
public java.awt.swing.plaf.TableHeaderUI getUI()
setUI
public void setUI(java.awt.swing.plaf.TableHeaderUI ui)
updateUI
public void updateUI()
- Overrides:
- updateUI in class JComponent
getUIClassID
public String getUIClassID()
- Returns:
- "TableHeaderUI"
- Overrides:
- getUIClassID in class JComponent
- See Also:
- getUIClassID, getUI
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()
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()
isOpaque
public boolean isOpaque()
- Overrides:
- isOpaque in class JComponent
columnAdded
public void columnAdded(TableColumnModelEvent e)
- Implements:
- columnAdded in interface TableColumnModelListener
columnRemoved
public void columnRemoved(TableColumnModelEvent e)
- Implements:
- columnRemoved in interface TableColumnModelListener
columnMoved
public void columnMoved(TableColumnModelEvent e)
- Implements:
- columnMoved in interface TableColumnModelListener
columnMarginChanged
public void columnMarginChanged(ChangeEvent e)
- Implements:
- columnMarginChanged in interface TableColumnModelListener
columnSelectionChanged
public void columnSelectionChanged(ListSelectionEvent e)
- Implements:
- columnSelectionChanged in interface TableColumnModelListener
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
initializeLocalVars
protected void initializeLocalVars()
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.
setDraggedColumn
public void setDraggedColumn(TableColumn aColumn)
- Sets the header's draggedColumn to aColumn
setDraggedDistance
public void setDraggedDistance(int distance)
- Sets the header's draggedDistance to distance
setResizingColumn
public void setResizingColumn(TableColumn aColumn)
- Sets the header's resizingColumn to aColumn
getAccessibleContext
public AccessibleContext getAccessibleContext()
- Get the AccessibleContext associated with this JComponent
- Implements:
- getAccessibleContext in interface Accessible
- Returns:
- the AccessibleContext of this JComponent
- Overrides:
- getAccessibleContext in class JComponent
Submit a bug or feature
Submit comments/suggestions about new javadoc look.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1993-1998 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.