public class JXTableHeader extends JTableHeader implements TableColumnModelExtListener
JXTable.toggleSortOrder(int)
,
JXTable.resetSortOrder()
,
SortGestureRecognizer
,
Serialized FormModifier and Type | Class and Description |
---|---|
private class |
JXTableHeader.HeaderListener
A MouseListener implementation to support enhanced tableHeader functionality.
|
JTableHeader.AccessibleJTableHeader
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
Modifier and Type | Field and Description |
---|---|
private MouseInputListener |
headerListener |
private static Logger |
LOG |
private boolean |
resortsOnDoubleClick |
private PropertyChangeListener |
tablePropertyChangeListener |
columnModel, draggedColumn, draggedDistance, reorderingAllowed, resizingAllowed, resizingColumn, table, updateTableInRealTime
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
JXTableHeader()
Constructs a
JTableHeader with a default
TableColumnModel . |
JXTableHeader(TableColumnModel columnModel)
Constructs a
JTableHeader which is initialized with
cm as the column model. |
Modifier and Type | Method and Description |
---|---|
void |
columnPropertyChange(PropertyChangeEvent event)
Implements TableColumnModelExt to allow internal update after
column property changes.
|
protected PropertyChangeListener |
createTablePropertyChangeListener()
Creates and returns the PropertyChangeListener to register on the
owning table.
|
TableCellRenderer |
getCellRenderer(int columnIndex)
Returns the TableCellRenderer to use for the column with the given index.
|
protected String |
getColumnToolTipText(MouseEvent event)
Returns the column tooltip of the column at the position
of the MouseEvent, if a tooltip is available.
|
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.
|
Dimension |
getPreferredSize()
Overridden to adjust for a reasonable minimum height.
|
protected Dimension |
getPreferredSize(Dimension pref)
Returns a preferred size which is adjusted to the maximum of all
header renderers' height requirement.
|
boolean |
getResortsOnDoubleClick()
Returns the resortsOnDoubleClick property.
|
protected PropertyChangeListener |
getTablePropertyChangeListener()
Returns the PropertyChangeListener to register on the owning table,
lazily created.
|
String |
getToolTipText(MouseEvent event)
Overridden to respect the column tooltip, if available.
|
private int |
getViewIndexForColumn(TableColumn aColumn)
Returns the (visible) view index for the table column
or -1 if not visible or not contained in this header's
columnModel.
|
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(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.
|
private boolean |
isVisible(TableColumn column)
Checks and returns the column's visibility.
|
void |
setDraggedColumn(TableColumn column) |
void |
setDraggedDistance(int distance)
Overridden to scroll the table to keep the dragged column visible.
|
void |
setResizingColumn(TableColumn aColumn) |
void |
setResortsOnDoubleClick(boolean resortsOnDoubleClick)
Sets the resortsOnDoubleClick property.
|
void |
setTable(JTable table)
Sets the associated JTable.
|
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.
|
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
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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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
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, transferFocusDownCycle, validate, validateTree
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, 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, transferFocusBackward, transferFocusUpCycle
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
columnAdded, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged
private transient PropertyChangeListener tablePropertyChangeListener
private boolean resortsOnDoubleClick
private MouseInputListener headerListener
public JXTableHeader()
JTableHeader
with a default
TableColumnModel
.JTableHeader.createDefaultColumnModel()
public JXTableHeader(TableColumnModel columnModel)
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
.columnModel
- the column model for the tableJTableHeader.createDefaultColumnModel()
public void setTable(JTable table)
Sets the associated JTable. Enables enhanced header features if table is of type JXTable.
PENDING: who is responsible for synching the columnModel?
setTable
in class JTableHeader
protected void installTable()
This implemenation synchs enabled state and installs the PropertyChangeListener.
protected void updateEnabledFromTable()
protected void uninstallTable()
This implementation uninstalls the PropertyChangeListener.
public void columnPropertyChange(PropertyChangeEvent event)
This implementation triggers a resizeAndRepaint on every propertyChange which doesn't already fire a "normal" columnModelEvent.
columnPropertyChange
in interface TableColumnModelExtListener
event
- change notification from a contained TableColumn.isColumnEvent(PropertyChangeEvent)
,
TableColumnModelExtListener
protected boolean isColumnEvent(PropertyChangeEvent event)
This implementation returns true for notification of width, preferredWidth and visible properties, false otherwise.
event
- the PropertyChangeEvent received as TableColumnModelExtListener.public String getToolTipText(MouseEvent event)
Overridden to respect the column tooltip, if available.
getToolTipText
in class JTableHeader
protected String getColumnToolTipText(MouseEvent event)
event
- the mouseEvent representing the mouse location.public JXTable getXTable()
public boolean getResortsOnDoubleClick()
setResortsOnDoubleClick(boolean)
public void setResortsOnDoubleClick(boolean resortsOnDoubleClick)
resortsOnDoubleClick
- a boolean indicating whether or not the
second click in a mouseClicked event should resort the column.getResortsOnDoubleClick()
public TableCellRenderer getCellRenderer(int columnIndex)
columnIndex
- the index in view coordinates of the columnpublic 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.
getPreferredSize
in class JComponent
getPreferredSize(Dimension)
,
getMinimumHeight(int).
protected Dimension getPreferredSize(Dimension pref)
pref
- an initial preferred sizegetPreferredSize()
,
getMinimumHeight(int)
protected int getMinimumHeight(int 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.
height
- the initial height.getPreferredSize()
,
getPreferredSize(Dimension)
public void setDraggedColumn(TableColumn column)
setDraggedColumn
in class JTableHeader
public void setResizingColumn(TableColumn aColumn)
setResizingColumn
in class JTableHeader
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.
setDraggedDistance
in class JTableHeader
public TableColumn getDraggedColumn()
null
.getDraggedColumn
in class JTableHeader
null
JTableHeader.getDraggedDistance()
private boolean isVisible(TableColumn column)
column
- the TableColumn
to checkprivate int getViewIndexForColumn(TableColumn aColumn)
aColumn
- the TableColumn to find the view index forprotected PropertyChangeListener getTablePropertyChangeListener()
protected PropertyChangeListener createTablePropertyChangeListener()
This implementation synchs the header's enabled properties with the table's enabled.
protected void installHeaderListener()
protected void uninstallHeaderListener()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses