JIDE 3.5.15

com.jidesoft.grid
Class SortableTableHeader

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.table.JTableHeader
                  extended by com.jidesoft.grid.DraggingTableHeader
                      extended by com.jidesoft.grid.CellStyleTableHeader
                          extended by com.jidesoft.grid.SortableTableHeader
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, TableColumnModelListener
Direct Known Subclasses:
EditableTableHeader

public class SortableTableHeader
extends CellStyleTableHeader

A special table header for SortableTable which draws arrows and index to indicate the sorting order.

SortableTableHeader introduced a very useful feature called TableHeaderCellDecorator which provides a way for users to paint over the margin of any table header's cells. SortableTableHeader uses it to paint the sort arrow and sort order index.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.table.JTableHeader
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.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
static String PROPERTY_SHOW_SORT_ARROW
           
 
Fields inherited from class com.jidesoft.grid.CellStyleTableHeader
_cellStyleList
 
Fields inherited from class com.jidesoft.grid.DraggingTableHeader
PROPERTY_DRAGGED_COLUMN, PROPERTY_DRAGGED_DISTANCE, PROPERTY_RESIZING_COLUMN
 
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
SortableTableHeader(JTable table)
          The constructor which takes JTable.
SortableTableHeader(TableColumnModel cm)
           
 
Method Summary
protected  TableHeaderCellDecorator createSortableTableHeaderCellDecorator()
          Creates a TableHeaderCellDecorator instance to paint the sort icon and index.
protected  Icon createSortIcon(SortableTable table, boolean ascending)
          Create the sort arrow icon.
 String getActualUIClassID()
          Returns a string that specifies the name of the L&F class that renders this component.
 TableHeaderCellDecorator getSortableTableHeaderCellDecorator()
          Gets the TableHeaderCellDecorator instance to paint the sort icon and index.
 String getUIDelegateClassID()
          Returns a string that specifies the name of the UIDelegate class that paints this component.
 boolean isShowSortArrow()
          Checks if the sort arrow is visible on the table header.
protected  void paintComponent(Graphics g)
          Overrides to paint the sort arrows on table header.
protected  void paintSortArrow(JComponent c, SortableTable table, Graphics g, Rectangle rect, int index, boolean ascending)
          Deprecated. replaced by SortableTableHeaderCellDecorator
protected  void paintSortArrows(Graphics g)
          Deprecated. replaced by SortableTableHeaderCellDecorator
 void setShowSortArrow(boolean showSortArrow)
          Sets the flag if the sort arrow is shown on the header.
 
Methods inherited from class com.jidesoft.grid.CellStyleTableHeader
addCellDecorator, addCellDecorator, addCellStyleCustomizer, clearCellStyleCustomizers, collectCellStyles, createToolTip, customizeRendererComponent, getActualHeaderY, getCellDecorators, getCellStyleAt, getCellStyleCustomizers, getDefaultCursor, mergeCellStyles, originalColumnAtPoint, releaseRendererComponent, removeCellDecorator, removeCellStyleCustomizer, setCursor, setDefaultRenderer, updateUI
 
Methods inherited from class com.jidesoft.grid.DraggingTableHeader
getPreferredSize, getToolTipText, setDraggedColumn, setDraggedDistance, setResizingColumn
 
Methods inherited from class javax.swing.table.JTableHeader
columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, createDefaultColumnModel, createDefaultRenderer, getAccessibleContext, getColumnModel, getDefaultRenderer, getDraggedColumn, getDraggedDistance, getHeaderRect, getReorderingAllowed, getResizingAllowed, getResizingColumn, getTable, getUI, getUIClassID, getUpdateTableInRealTime, initializeLocalVars, paramString, resizeAndRepaint, setColumnModel, setReorderingAllowed, setResizingAllowed, setTable, setUI, setUpdateTableInRealTime
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, 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, 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, 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
 

Field Detail

PROPERTY_SHOW_SORT_ARROW

public static final String PROPERTY_SHOW_SORT_ARROW
See Also:
Constant Field Values
Constructor Detail

SortableTableHeader

public SortableTableHeader(TableColumnModel cm)

SortableTableHeader

public SortableTableHeader(JTable table)
The constructor which takes JTable.

Parameters:
table - the JTable
Since:
3.1.0
Method Detail

getActualUIClassID

public String getActualUIClassID()
Returns a string that specifies the name of the L&F class that renders this component.

Overrides:
getActualUIClassID in class CellStyleTableHeader
Returns:
the string "SortableTableHeaderUI"

getUIDelegateClassID

public String getUIDelegateClassID()
Returns a string that specifies the name of the UIDelegate class that paints this component.

Overrides:
getUIDelegateClassID in class CellStyleTableHeader
Returns:
the string "TableHeader.sortableTableHeaderUIDelegate"

paintComponent

protected void paintComponent(Graphics g)
Overrides to paint the sort arrows on table header.

Overrides:
paintComponent in class DraggingTableHeader
Parameters:
g - the Graphics object

paintSortArrows

@Deprecated
protected void paintSortArrows(Graphics g)
Deprecated. replaced by SortableTableHeaderCellDecorator

Paints the sort arrows.

Parameters:
g - the Graphics object

paintSortArrow

@Deprecated
protected void paintSortArrow(JComponent c,
                                         SortableTable table,
                                         Graphics g,
                                         Rectangle rect,
                                         int index,
                                         boolean ascending)
Deprecated. replaced by SortableTableHeaderCellDecorator

Paints the sort arrow.

Parameters:
c - table header
table - the sortable table.
g - Graphics
rect - the bounds of the table column header
index - the sorting index
ascending - the sorting direction.

createSortIcon

protected Icon createSortIcon(SortableTable table,
                              boolean ascending)
Create the sort arrow icon. Subclass can override it to create your own sort arrow. Although the name is createSortIcon, you could cache the icon internally and don't create it every time when this method is called.

Parameters:
table - the sortable table.
ascending - true or false. True is ascending.
Returns:
the sort arrow icon.

isShowSortArrow

public boolean isShowSortArrow()
Checks if the sort arrow is visible on the table header.

Moved from AutoFilterTableHeader since 3.1.0.

Returns:
true or false.
Since:
3.1.0

setShowSortArrow

public void setShowSortArrow(boolean showSortArrow)
Sets the flag if the sort arrow is shown on the header.

Moved from AutoFilterTableHeader since 3.1.0.

Parameters:
showSortArrow - true to show the sort arrow. False to not show it.
Since:
3.1.0

getSortableTableHeaderCellDecorator

public TableHeaderCellDecorator getSortableTableHeaderCellDecorator()
Gets the TableHeaderCellDecorator instance to paint the sort icon and index.

Returns:
the SortableTableHeaderCellDecorator instance.
Since:
3.1.0

createSortableTableHeaderCellDecorator

protected TableHeaderCellDecorator createSortableTableHeaderCellDecorator()
Creates a TableHeaderCellDecorator instance to paint the sort icon and index.

Returns:
a SortableTableHeaderCellDecorator instance.
Since:
3.1.0

JIDE 3.5.15