Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jdesktop.swingx
Class JXTableHeader

    java.lang.Object
      java.awt.Component
          java.awt.Container
              javax.swing.JComponent
                  javax.swing.table.JTableHeader
                      org.jdesktop.swingx.JXTableHeader

All Implemented Interfaces:
  java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, javax.swing.event.TableColumnModelListener, TableColumnModelExtListener

    public class JXTableHeader

extends javax.swing.table.JTableHeader
implements TableColumnModelExtListener

TableHeader with extended functionality if associated Table is of type JXTable.

## Extended user interaction

- Note: this is currently (?) disabled due to missing core functionality. Supports column sorting by mouse clicks into a header cell (outside the resize region). The concrete gestures are configurable by providing a custom SortGestureRecognizer. The default recognizer toggles sort order on mouseClicked. On shift-mouseClicked, it resets any column sorting. Both are done by invoking the corresponding methods of JXTable, `toggleSortOrder(int)` and `resetSortOrder()`
- Supports column pack (== auto-resize to exactly fit the contents) on double-click in resize region. Note: this is only fully effective if the JXTable has control over the row sorter, that is if the row sorter is of type SortController.
- Supports horizontal auto-scroll if a column is dragged outside visible rectangle. This feature is enabled if the autoscrolls property is true. The default is false (because of Issue #788-swingx which still isn't fixed for jdk1.6).

## Extended functionality

- Installs a default header renderer which is able to show sort icons. LAF provided special effects are uneffected.
- Listens to TableColumn propertyChanges to update itself accordingly.
- Supports per-column header ToolTips.
- Guarantees reasonable minimal height > 0 for header preferred height.
- Does its best to not sort if the mouse click happens in the resize region. Note: this is only fully effective if the JXTable has control over the row sorter, that is if the row sorter is of type SortController.

Author:
  Jeanette Winzenburg
See Also:
  `JXTable.toggleSortOrder(int)`, `JXTable.resetSortOrder()`, `JXTableHeader.SortGestureRecognizer`, Serialized Form

Nested Class Summary
`static class` | `JXTableHeader.SortGestureRecognizer` Deprecated. no longer used internally - keep until we know better how to meet our requirments in Mustang

Nested classes/interfaces inherited from class javax.swing.table.JTableHeader
`javax.swing.table.JTableHeader.AccessibleJTableHeader`

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

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

Nested classes/interfaces inherited from class java.awt.Component
`java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy`

Field Summary

Fields inherited from class javax.swing.table.JTableHeader
`columnModel, draggedColumn, draggedDistance, reorderingAllowed, resizingAllowed, resizingColumn, table, updateTableInRealTime`

Fields inherited from class javax.swing.JComponent
`accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW`

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
`JXTableHeader()` Constructs a `JTableHeader` with a default `TableColumnModel`.
`JXTableHeader(javax.swing.table.TableColumnModel columnModel)` Constructs a `JTableHeader` which is initialized with `cm` as the column model.

Method Summary
`void` | `columnPropertyChange(java.beans.PropertyChangeEvent event)` Implements TableColumnModelExt to allow internal update after column property changes.
`protected JXTableHeader.SortGestureRecognizer` | `createSortGestureRecognizer()` Deprecated. no longer used internally - keep until we know better how to meet our requirments in Mustang
`protected java.beans.PropertyChangeListener` | `createTablePropertyChangeListener()` Creates and returns the PropertyChangeListener to register on the owning table.
`javax.swing.table.TableCellRenderer` | `getCellRenderer(int columnIndex)` Returns the TableCellRenderer to use for the column with the given index.
`protected java.lang.String` | `getColumnToolTipText(java.awt.event.MouseEvent event)` Returns the column tooltip of the column at the position of the MouseEvent, if a tooltip is available.
`javax.swing.table.TableColumn` | `getDraggedColumn()` Returns the the dragged column if and only if, a drag is in process and the column is visible, otherwise returns `null`.
`protected int` | `getMinimumHeight(int height)` Returns a reasonable minimal preferred height for the header.
`java.awt.Dimension` | `getPreferredSize()`
`protected java.awt.Dimension` | `getPreferredSize(java.awt.Dimension pref)` Returns a preferred size which is adjusted to the maximum of all header renderers' height requirement.
`JXTableHeader.SortGestureRecognizer` | `getSortGestureRecognizer()` Deprecated. no longer used internally - keep until we know better how to meet our requirments in Mustang
`protected java.beans.PropertyChangeListener` | `getTablePropertyChangeListener()` Returns the PropertyChangeListener to register on the owning table, lazily created.
`java.lang.String` | `getToolTipText(java.awt.event.MouseEvent event)`
`JXTable` | `getXTable()` Returns the associated table if it is of type JXTable, or null if not.
`protected void` | `installHeaderListener()` Creates and installs header listeners to service the extended functionality.
`protected void` | `installTable()` Installs the table.
`protected boolean` | `isColumnEvent(java.beans.PropertyChangeEvent event)` Returns a boolean indicating if a property change event received from column changes is expected to be already broadcasted by the core TableColumnModel.
`void` | `setDraggedColumn(javax.swing.table.TableColumn column)`
`void` | `setDraggedDistance(int distance)`
`void` | `setResizingColumn(javax.swing.table.TableColumn aColumn)`
`void` | `setSortGestureRecognizer(JXTableHeader.SortGestureRecognizer recognizer)` Deprecated. no longer used internally - keep until we know better how to meet our requirments in Mustang
`void` | `setTable(javax.swing.JTable table)`
`protected void` | `uninstallHeaderListener()` Uninstalls header listeners to service the extended functionality.
`protected void` | `uninstallTable()` Uninstalls the table.
`protected void` | `updateEnabledFromTable()` Synchs the header's enabled with the table's enabled property.

Methods inherited from class javax.swing.table.JTableHeader
`columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, createDefaultColumnModel, createDefaultRenderer, getAccessibleContext, getColumnModel, getDefaultRenderer, getDraggedDistance, getHeaderRect, getReorderingAllowed, getResizingAllowed, getResizingColumn, getTable, getUI, getUIClassID, getUpdateTableInRealTime, initializeLocalVars, paramString, resizeAndRepaint, setColumnModel, setDefaultRenderer, setReorderingAllowed, setResizingAllowed, setUI, setUpdateTableInRealTime, updateUI`

Methods inherited from class javax.swing.JComponent
`addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, 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, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update`

Methods inherited from class java.awt.Container
`add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree`

Methods inherited from class java.awt.Component
`action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface javax.swing.event.TableColumnModelListener
`columnAdded, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged`

Constructor Detail

### JXTableHeader

    public JXTableHeader()

  Constructs a `JTableHeader` with a default `TableColumnModel`.

  See Also:
    `JTableHeader.createDefaultColumnModel()`

### JXTableHeader

    public JXTableHeader(javax.swing.table.TableColumnModel columnModel)

  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:
    `columnModel` - the column model for the table
  See Also:
    `JTableHeader.createDefaultColumnModel()`

Method Detail

### setTable

    public void setTable(javax.swing.JTable table)

  Sets the associated JTable. Enables enhanced header features if table is of type JXTable.

  PENDING: who is responsible for synching the columnModel?

  Overrides:
    `setTable` in class `javax.swing.table.JTableHeader`

### installTable

    protected void installTable()

  Installs the table.

  This implemenation synchs enabled state and installs the PropertyChangeListener.

### updateEnabledFromTable

    protected void updateEnabledFromTable()

  Synchs the header's enabled with the table's enabled property.

### uninstallTable

    protected void uninstallTable()

  Uninstalls the table.

  This implementation uninstalls the PropertyChangeListener.

### columnPropertyChange

    public void columnPropertyChange(java.beans.PropertyChangeEvent event)

  Implements TableColumnModelExt to allow internal update after column property changes.

  This implementation triggers a resizeAndRepaint on every propertyChange which doesn't already fire a "normal" columnModelEvent.

  Specified by:
    `columnPropertyChange` in interface `TableColumnModelExtListener`
  Parameters:
    `event` - change notification from a contained TableColumn.
  See Also:
    `isColumnEvent(PropertyChangeEvent)`, `TableColumnModelExtListener`

### isColumnEvent

    protected boolean isColumnEvent(java.beans.PropertyChangeEvent event)

  Returns a boolean indicating if a property change event received from column changes is expected to be already broadcasted by the core TableColumnModel.

  This implementation returns true for notification of width, preferredWidth and visible properties, false otherwise.

  Parameters:
    `event` - the PropertyChangeEvent received as TableColumnModelExtListener.
  Returns:
    a boolean to decide whether the same event triggers a base columnModelEvent.

### getToolTipText

    public java.lang.String getToolTipText(java.awt.event.MouseEvent event)

  Overridden to respect the column tooltip, if available.

  Overrides:
    `getToolTipText` in class `javax.swing.table.JTableHeader`
  Returns:
    the column tooltip of the column at the mouse position if not null or super if not available.

### getColumnToolTipText

    protected java.lang.String getColumnToolTipText(java.awt.event.MouseEvent event)

  Returns the column tooltip of the column at the position of the MouseEvent, if a tooltip is available.

  Parameters:
    `event` - the mouseEvent representing the mouse location.
  Returns:
    the column tooltip of the column below the mouse location, or null if not available.

### getXTable

    public JXTable getXTable()

  Returns the associated table if it is of type JXTable, or null if not.

  Returns:
    the associated table if of type JXTable or null if not.

### getCellRenderer

    public javax.swing.table.TableCellRenderer getCellRenderer(int columnIndex)

  Returns the TableCellRenderer to use for the column with the given index. This implementation returns the column's header renderer if available or this header's default renderer if not.

  Parameters:
    `columnIndex` - the index in view coordinates of the column
  Returns:
    the renderer to use for the column, guaranteed to be not null.

### getPreferredSize

    public java.awt.Dimension getPreferredSize()

  Overridden to adjust for a reasonable minimum height. Done to fix Issue 334-swingx, which actually is a core issue misbehaving in returning a zero height if the first column has no text.

  Overrides:
    `getPreferredSize` in class `javax.swing.JComponent`
  See Also:
    `getPreferredSize(Dimension)`, `getMinimumHeight(int).`

### getPreferredSize

    protected java.awt.Dimension getPreferredSize(java.awt.Dimension pref)

  Returns a preferred size which is adjusted to the maximum of all header renderers' height requirement.

  Parameters:
    `pref` - an initial preferred size
  Returns:
    the initial preferred size with its height property adjusted to the maximum of all renderers preferred height requirement.
  See Also:
    `getPreferredSize()`, `getMinimumHeight(int)`

### getMinimumHeight

    protected int getMinimumHeight(int height)

  Returns a reasonable minimal preferred height for the header. This is meant as a last straw if all header values are null, renderers report 0 as their preferred height.

  This implementation returns the default header renderer's preferred height as measured with a dummy value if the input height is 0, otherwise returns the height unchanged.

  Parameters:
    `height` - the initial height.
  Returns:
    a reasonable minimal preferred height.
  See Also:
    `getPreferredSize()`, `getPreferredSize(Dimension)`

### setDraggedColumn

    public void setDraggedColumn(javax.swing.table.TableColumn column)

  Overrides:
    `setDraggedColumn` in class `javax.swing.table.JTableHeader`

### setResizingColumn

    public void setResizingColumn(javax.swing.table.TableColumn aColumn)

  Overrides:
    `setResizingColumn` in class `javax.swing.table.JTableHeader`

### setDraggedDistance

    public void setDraggedDistance(int distance)

  Overridden to scroll the table to keep the dragged column visible. This side-effect is enabled only if the header's autoscroll property is `true` and the associated table is of type JXTable.

  The autoscrolls is disabled by default. With or without - core issue #6503981 has weird effects (for jdk 1.6 - 1.6u3) on a plain JTable as well as a JXTable, fixed in 1.6u4.

  Overrides:
    `setDraggedDistance` in class `javax.swing.table.JTableHeader`

### getDraggedColumn

    public javax.swing.table.TableColumn getDraggedColumn()

  Returns the the dragged column if and only if, a drag is in process and the column is visible, otherwise returns `null`.

  Overrides:
    `getDraggedColumn` in class `javax.swing.table.JTableHeader`
  Returns:
    the dragged column, if a drag is in process and the column is visible, otherwise returns `null`
  See Also:
    `JTableHeader.getDraggedDistance()`

### getTablePropertyChangeListener

    protected java.beans.PropertyChangeListener getTablePropertyChangeListener()

  Returns the PropertyChangeListener to register on the owning table, lazily created.

  Returns:
    the PropertyChangeListener to use on the owning table.

### createTablePropertyChangeListener

    protected java.beans.PropertyChangeListener createTablePropertyChangeListener()

  Creates and returns the PropertyChangeListener to register on the owning table.

  This implementation synchs the header's enabled properties with the table's enabled.

  Returns:
    the PropertyChangeListener to register on the owning table.

### installHeaderListener

    protected void installHeaderListener()

  Creates and installs header listeners to service the extended functionality. This implementation creates and installs a custom mouse input listener.

### uninstallHeaderListener

    protected void uninstallHeaderListener()

  Uninstalls header listeners to service the extended functionality. This implementation uninstalls a custom mouse input listener.

### getSortGestureRecognizer

    @Deprecated
    public JXTableHeader.SortGestureRecognizer getSortGestureRecognizer()

  Deprecated. no longer used internally - keep until we know better how to meet our requirments in Mustang

  Returns the SortGestureRecognizer to use. If none available, lazily creates a default.

  Returns:
    the SortGestureRecognizer to use for interpreting mouse events as sort gestures.
  See Also:
    `setSortGestureRecognizer(SortGestureRecognizer)`, `createSortGestureRecognizer()`

### setSortGestureRecognizer

    @Deprecated
    public void setSortGestureRecognizer(JXTableHeader.SortGestureRecognizer recognizer)

  Deprecated. no longer used internally - keep until we know better how to meet our requirments in Mustang

  Sets the SortGestureRecognizer to use for interpreting mouse events as sort gestures. If null, a default as returned by createSortGestureRecognizer is used.

  This is a bound property.

  Parameters:
    `recognizer` - the SortGestureRecognizer to use for interpreting mouse events as sort gestures
  See Also:
    `getSortGestureRecognizer()`, `createSortGestureRecognizer()`

### createSortGestureRecognizer

    @Deprecated
    protected JXTableHeader.SortGestureRecognizer createSortGestureRecognizer()

  Deprecated. no longer used internally - keep until we know better how to meet our requirments in Mustang

  Creates and returns the default SortGestureRecognizer.

  Returns:
    the default SortGestureRecognizer to use for interpreting mouse events as sort gestures.
  See Also:
    `getSortGestureRecognizer()`, `setSortGestureRecognizer(SortGestureRecognizer)`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010. All Rights Reserved.