JIDE 3.5.15

com.jidesoft.grid
Class NestedTableHeader

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
                              extended by com.jidesoft.grid.EditableTableHeader
                                  extended by com.jidesoft.grid.AutoFilterTableHeader
                                      extended by com.jidesoft.grid.NestedTableHeader
All Implemented Interfaces:
FilterableTableModelListener, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, CellEditorListener, TableColumnModelListener
Direct Known Subclasses:
NestedSortableTableHeader

public class NestedTableHeader
extends AutoFilterTableHeader

A table header supporting nested table columns.

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
protected  Vector<TableColumn> _columnGroups
           
static String PROPERTY_ORIGINAL_TABLE_HEADER_VISIBLE
           
 
Fields inherited from class com.jidesoft.grid.AutoFilterTableHeader
_autoFilterEnabled, _filterableTableModel, CLIENT_PROPERTY_CUSTOM_FILTER_EDITOR_TYPE, CUSTOM_FILTER_EDITOR_TYPE_TABLE_CUSTOM_FILTER_EDITOR, PROPERTY_ACCEPT_TEXT_INPUT, PROPERTY_AUTO_FILTER_ENABLED, PROPERTY_USE_NATIVE_CELL_RENDERER
 
Fields inherited from class com.jidesoft.grid.EditableTableHeader
_cellEditor, _defaultEditor, _editingColumn, _editorComp, HEADER_ROW
 
Fields inherited from class com.jidesoft.grid.SortableTableHeader
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
NestedTableHeader(JTable table)
          The constructor that takes table.
NestedTableHeader(TableColumnModel model)
           
 
Method Summary
 void addColumnGroup(TableColumnGroup group)
          Adds a column group to table header.
 void clearColumnGroups()
          Removes all column groups.
 int columnAtPoint(Point point)
           
 JToolTip createToolTip()
           
 int getActualHeaderY()
          Gets the start Y of actual table header.
 String getActualUIClassID()
          Returns a string that specifies the name of the L&F class that renders this component.
 Rectangle getCellRect(int row, int column)
           
 CellSpan getCellSpanAt(int rowIndex, int columnIndex)
          Gets the cell span of the nested table header.
 int getColumnCount()
           
 Enumeration getColumnGroups(TableColumn column)
          Gets an enumeration of table column groups.
 Rectangle getHeaderRect(int column)
           
 Object getHeaderValueAt(int rowIndex, int columnIndex)
          Gets the header value at the specified cell.
 int getLevel(TableColumn column)
          Gets the level of the TableColumn.
 int getMargin()
          Gets the margin between TableColumn's.
 Object getParent(TableColumn column)
          Gets the parent of the table column.
 int getRowAt(TableColumn column)
          Gets the starts row index for the column.
 int getRowCount()
          Gets the row count since it has nested table header.
 TableColumnGroup getTableColumnGroup(int rowIndex, int columnIndex)
          Get the corresponding TableColumnGroup in the designated row and column.
 TableColumn[] getTableColumnGroups()
          Gets all the TableColumnGroups added to NestedtableHeader as an array.
 String getUIDelegateClassID()
          Returns a string that specifies the name of the UIDelegate class that paints this component.
 boolean isMouseOnOriginalTableHeader(Point point)
          Check if the mouse point is on the original table header
 boolean isOriginalTableHeaderVisible()
          Checks if the original table header is visible.
 int originalColumnAtPoint(Point point)
          Gets column at point disregarding the Y.
 Rectangle originalGetCellRect(int row, int column)
           
 void removeColumnGroup(TableColumnGroup group)
          Removes a column group to table header.
 int rowAtPoint(Point p)
          Returns the index of the row that point lies in.
 void setMargin(int margin)
          Sets the margin between TableColumn's.
 void setOriginalTableHeaderVisible(boolean originalTableHeaderVisible)
          Shows or hides the original table header visible.
protected  void tableModelChanged(JTable table)
          This method will be called when TableModel on JTable is changed.
 
Methods inherited from class com.jidesoft.grid.AutoFilterTableHeader
clearFilters, columnMarginChanged, createDefaultEditor, createDefaultFilterableTableModel, createDefaultRenderer, createFilterableTableHeaderCellDecorator, createFilterableTableModel, customizeAutoFilterBox, editingStopped, filterableTableModelChanged, formatColumnTitle, getAutoFilterTableHeaderRenderer, getFilterableTableHeaderCellDecorator, getFilterableTableModel, getFilterableTableModel, getFilterIcon, getFormattedColumnName, getToolTipText, initTable, isAcceptTextInput, isAllowMultipleValues, isAllowMultipleValues, isAutoFilterEnabled, isAutoRequestFocus, isCellEditable, isPreferSelectedValues, isRolloverEnabled, isShowFilterIcon, isShowFilterName, isShowFilterNameAsToolTip, isUseNativeHeaderRenderer, propertyChange, setAcceptTextInput, setAllowMultipleValues, setAutoFilterEnabled, setPreferSelectedValues, setShowFilterIcon, setShowFilterName, setShowFilterNameAsToolTip, setShowSortArrow, setTable, setUseNativeHeaderRenderer
 
Methods inherited from class com.jidesoft.grid.EditableTableHeader
cancelEditing, customizeEditorComponent, editCellAt, editCellAt, editingCanceled, getCellEditor, getCellEditor, getDefaultEditor, getEditingColumn, getEditorComponent, isClickToStartEditing, isEditing, prepareEditor, removeEditor, removeNotify, resizeAndRepaint, setCellEditor, setClickToStartEditing, setDefaultEditor, setDraggedColumn, setEditingColumn, setRolloverEnabled, stopEditing
 
Methods inherited from class com.jidesoft.grid.SortableTableHeader
createSortableTableHeaderCellDecorator, createSortIcon, getSortableTableHeaderCellDecorator, isShowSortArrow, paintComponent, paintSortArrow, paintSortArrows
 
Methods inherited from class com.jidesoft.grid.CellStyleTableHeader
addCellDecorator, addCellDecorator, addCellStyleCustomizer, clearCellStyleCustomizers, collectCellStyles, customizeRendererComponent, getCellDecorators, getCellStyleAt, getCellStyleCustomizers, getDefaultCursor, mergeCellStyles, releaseRendererComponent, removeCellDecorator, removeCellStyleCustomizer, setCursor, setDefaultRenderer, updateUI
 
Methods inherited from class com.jidesoft.grid.DraggingTableHeader
getPreferredSize, setDraggedDistance, setResizingColumn
 
Methods inherited from class javax.swing.table.JTableHeader
columnAdded, columnMoved, columnRemoved, columnSelectionChanged, createDefaultColumnModel, getAccessibleContext, getColumnModel, getDefaultRenderer, getDraggedColumn, getDraggedDistance, getReorderingAllowed, getResizingAllowed, getResizingColumn, getTable, getUI, getUIClassID, getUpdateTableInRealTime, initializeLocalVars, paramString, setColumnModel, setReorderingAllowed, setResizingAllowed, 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, 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

_columnGroups

protected Vector<TableColumn> _columnGroups

PROPERTY_ORIGINAL_TABLE_HEADER_VISIBLE

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

NestedTableHeader

public NestedTableHeader(TableColumnModel model)

NestedTableHeader

public NestedTableHeader(JTable table)
The constructor that takes table.

Parameters:
table - the table
Since:
3.1.0
Method Detail

getHeaderRect

public Rectangle getHeaderRect(int column)
Overrides:
getHeaderRect in class JTableHeader

getActualUIClassID

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

Overrides:
getActualUIClassID in class AutoFilterTableHeader
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 AutoFilterTableHeader
Returns:
the string "TableHeader.nestedTableHeaderUIDelegate"
Since:
3.1.0

tableModelChanged

protected void tableModelChanged(JTable table)
Description copied from class: AutoFilterTableHeader
This method will be called when TableModel on JTable is changed.

Overrides:
tableModelChanged in class AutoFilterTableHeader
Parameters:
table - the table

getTableColumnGroups

public TableColumn[] getTableColumnGroups()
Gets all the TableColumnGroups added to NestedtableHeader as an array.

Returns:
the all the TableColumnGroups as an array.

addColumnGroup

public void addColumnGroup(TableColumnGroup group)
Adds a column group to table header. You only need to add the outermost table column group to table header.

Parameters:
group - TableColumnGroup to be added.
See Also:
getTableColumnGroups()

removeColumnGroup

public void removeColumnGroup(TableColumnGroup group)
Removes a column group to table header.

Parameters:
group - TableColumnGroup to be removed.

clearColumnGroups

public void clearColumnGroups()
Removes all column groups.


getParent

public Object getParent(TableColumn column)
Gets the parent of the table column.

Parameters:
column - the TableColumn.
Returns:
the parent of the table column.

rowAtPoint

public int rowAtPoint(Point p)
Returns the index of the row that point lies in.

Parameters:
p - the point
Returns:
the row index. -1 if it lies out of bounds.

getColumnGroups

public Enumeration getColumnGroups(TableColumn column)
Gets an enumeration of table column groups.

Parameters:
column - the TableColumn.
Returns:
the enumeration of the ancestors of table column.

getRowAt

public int getRowAt(TableColumn column)
Gets the starts row index for the column.

Parameters:
column - the TableColumn instance.
Returns:
the table column group vector of all the column's ancestors
Since:
3.2.0

getLevel

public int getLevel(TableColumn column)
Gets the level of the TableColumn.

Parameters:
column - the TableColumn
Returns:
the level.

isOriginalTableHeaderVisible

public boolean isOriginalTableHeaderVisible()
Checks if the original table header is visible.

Returns:
true if visible. Otherwise false.

setOriginalTableHeaderVisible

public void setOriginalTableHeaderVisible(boolean originalTableHeaderVisible)
Shows or hides the original table header visible. It is true by default. If you need hide the original table header and only show the nested table header above it, you can call this method and set it to false.

Parameters:
originalTableHeaderVisible - true or false.

isMouseOnOriginalTableHeader

public boolean isMouseOnOriginalTableHeader(Point point)
Check if the mouse point is on the original table header

Parameters:
point - mouse point
Returns:
false if the point is on the group columns. Otherwise true.

getTableColumnGroup

public TableColumnGroup getTableColumnGroup(int rowIndex,
                                            int columnIndex)
Get the corresponding TableColumnGroup in the designated row and column.

Parameters:
rowIndex - the row index
columnIndex - the column index
Returns:
TableColumnGroup instance if it is a group. null if it is just a TableColumn or other objects.

getRowCount

public int getRowCount()
Gets the row count since it has nested table header.

Returns:
the row count.

getColumnCount

public int getColumnCount()

getCellSpanAt

public CellSpan getCellSpanAt(int rowIndex,
                              int columnIndex)
Gets the cell span of the nested table header.

Parameters:
rowIndex - the row index.
columnIndex - the column index.
Returns:
the cell span for the specified cell.

originalGetCellRect

public Rectangle originalGetCellRect(int row,
                                     int column)

getCellRect

public Rectangle getCellRect(int row,
                             int column)

getActualHeaderY

public int getActualHeaderY()
Description copied from class: CellStyleTableHeader
Gets the start Y of actual table header.

In NestedTableHeader and GroupTableHeader scenarios, this method will return different value other than 0.

Overrides:
getActualHeaderY in class CellStyleTableHeader
Returns:
0 by default.

columnAtPoint

public int columnAtPoint(Point point)
Overrides:
columnAtPoint in class JTableHeader

originalColumnAtPoint

public int originalColumnAtPoint(Point point)
Description copied from class: CellStyleTableHeader
Gets column at point disregarding the Y.

Overrides:
originalColumnAtPoint in class CellStyleTableHeader
Parameters:
point - the mouse point
Returns:
the view column index. -1 if no column is found on the header.

getHeaderValueAt

public Object getHeaderValueAt(int rowIndex,
                               int columnIndex)
Gets the header value at the specified cell.

Parameters:
rowIndex - the row index.
columnIndex - the column index.
Returns:
the header value at the specified cell.

getMargin

public int getMargin()
Gets the margin between TableColumn's.

Returns:
the margin.
See Also:
setMargin(int)

setMargin

public void setMargin(int margin)
Sets the margin between TableColumn's.

By default, the value is 0.

Parameters:
margin - the margin

createToolTip

public JToolTip createToolTip()
Overrides:
createToolTip in class CellStyleTableHeader

JIDE 3.5.15