APIdia Launch Partner
Top Description Fields Constructors Methods
javafx.scene.control.skin

public Class TableHeaderRow

extends StackPane
Class Inheritance
Imports
java.util.*, javafx.beans.InvalidationListener, .WeakInvalidationListener, javafx.beans.property.BooleanProperty, .DoubleProperty, .ReadOnlyObjectProperty, .ReadOnlyObjectWrapper, .SimpleBooleanProperty, .SimpleDoubleProperty, .StringProperty, javafx.beans.value.ChangeListener, .WeakChangeListener, javafx.collections.ListChangeListener, .WeakListChangeListener, javafx.geometry.Bounds, .HPos, .Insets, .Side, .VPos, javafx.scene.control.CheckMenuItem, .ContextMenu, .Control, .Label, .TableColumnBase, javafx.scene.input.MouseEvent, javafx.scene.layout.Pane, .Region, .StackPane, javafx.scene.shape.Rectangle, com.sun.javafx.scene.control.skin.resources.ControlResources

Region responsible for painting the entire row of column headers.
Since
9
See Also
javafx.scene.control.TableView, TableViewSkin, javafx.scene.control.TreeTableView, TreeTableViewSkin

Field Summary

Modifier and TypeField and Description
private Rectangle
pack-priv boolean
columnDragLock

There are two different mouse dragged event handlers in the header code.

private Map<TableColumnBase<S, T>, CheckMenuItem>
private ContextMenu
columnPopupMenu

PopupMenu shown to users to allow for them to hide/show columns in the table.

private final InvalidationListener
pack-priv final DoubleProperty
private final ChangeListener<Boolean>
private Pane
cornerRegion

This is the region where the user can interact with to show/hide columns.

private StackPane
dragHeader

This is the ghosted region representing the table column that is being dragged.

private final Label
private Region
private final VirtualFlow<T extends IndexedCell<T>>
private BooleanProperty
reordering

Indicates if a reordering operation of a column is in progress.

private TableColumnHeader
private ReadOnlyObjectWrapper<NestedTableColumnHeader>
private double
private final ListChangeListener<E>
private InvalidationListener
pack-priv final TableViewSkinBase<?, ?, ?, ?, ?>
private double
private InvalidationListener
private InvalidationListener
private ListChangeListener<E>
private final WeakInvalidationListener
private final WeakChangeListener<Boolean>
private final WeakListChangeListener<E>
private final WeakInvalidationListener
private final WeakInvalidationListener
private final WeakInvalidationListener
private final WeakListChangeListener<E>

Constructor Summary

AccessConstructor and Description
public
TableHeaderRow(final TableViewSkinBase<M, S, C extends Control, I extends IndexedCell<M>, TC extends TableColumnBase<S, ?>>
The skin used by the UI control.
skin
)

Creates a new TableHeaderRow instance to visually represent the column header area of controls such as javafx.scene.control.TableView and javafx.scene.control.TreeTableView.

Method Summary

Modifier and TypeMethod and Description
protected double
computeMinHeight(double width)

Overrides javafx.scene.layout.StackPane.computeMinHeight.

Computes the minimum height of this region.

protected double
computePrefHeight(double width)

Overrides javafx.scene.layout.StackPane.computePrefHeight.

Computes the preferred height of this region for the given width; Region subclasses should override this method to return an appropriate value based on their content and layout strategy.

protected double
computePrefWidth(double height)

Overrides javafx.scene.layout.StackPane.computePrefWidth.

Computes the preferred width of this region for the given height.

private void
protected NestedTableColumnHeader

Returns:

A new NestedTableColumnHeader instance.
createRootHeader
()

Creates a new NestedTableColumnHeader instance.

pack-priv TableColumnHeader
private TableColumnHeader
getColumnHeaderFor(final TableColumnBase<?, ?> col, TableColumnHeader currentHeader)

pack-priv ContextMenu
pack-priv Pane
private List<TableColumnBase<?, ?>>
protected TableColumnHeader

Returns:

the current TableColumnHeader being moved
getReorderingRegion
()

Returns the current TableColumnHeader being moved during reordering.

public final NestedTableColumnHeader

Returns:

the root header
getRootHeader
()

Returns the root header for all columns.

private String
getText(String text, TableColumnBase<S, T> col)

private boolean
public final boolean
protected void
layoutChildren()

Overrides javafx.scene.layout.StackPane.layoutChildren.

Invoked during the layout pass to layout the children in this Parent.

private void
private void
public final BooleanProperty
private final ReadOnlyObjectProperty<NestedTableColumnHeader>
pack-priv void
setDragHeaderX(double dragHeaderX)

public final void
setReordering(boolean value)

pack-priv void
protected void
setReorderingRegion(TableColumnHeader
the TableColumnHeader being reordered
reorderingRegion
)

Sets the TableColumnHeader that is being moved during a reordering operation.

private final void
protected void
showColumnMenu(MouseEvent
the MouseEvent which was generated when the table menu button was pressed
mouseEvent
)

Shows a menu containing all leaf columns as items.

private void
protected void
updateScrollX()

Called whenever the value of the horizontal scrollbar changes in order to request layout changes, shifting the TableColumnHeaders.

private void
updateTableColumnListeners(List<? extends TableColumnBase<?, ?>> added, List<? extends TableColumnBase<?, ?>> removed)

protected void
updateTableWidth()

Updates the table width when a resize operation occurs.

Inherited from javafx.scene.layout.StackPane:
alignmentPropertyclearConstraintscomputeMinWidthgetAlignmentgetAlignmentgetClassCssMetaDatagetContentBiasgetCssMetaDatagetMarginrequestLayoutsetAlignmentsetAlignmentsetMargin

Field Detail

clipback to summary
private Rectangle clip
columnDragLockback to summary
pack-priv boolean columnDragLock

There are two different mouse dragged event handlers in the header code. Firstly, the column reordering functionality, and secondly, the column resizing functionality. Because these are handled in separate classes and with separate event handlers, we occasionally run into the issue where both event handlers were being called, resulting in bad UX. To remove this issue, we lock when the column dragging happens, and prevent resize operations from taking place.

columnMenuItemsback to summary
private Map<TableColumnBase<S, T>, CheckMenuItem> columnMenuItems
columnPopupMenuback to summary
private ContextMenu columnPopupMenu

PopupMenu shown to users to allow for them to hide/show columns in the table.

columnTextListenerback to summary
private final InvalidationListener columnTextListener
cornerPaddingback to summary
pack-priv final DoubleProperty cornerPadding
cornerPaddingListenerback to summary
private final ChangeListener<Boolean> cornerPaddingListener
cornerRegionback to summary
private Pane cornerRegion

This is the region where the user can interact with to show/hide columns. It is positioned in the top-right hand corner of the TableHeaderRow, and when clicked shows a PopupMenu consisting of all leaf columns.

dragHeaderback to summary
private StackPane dragHeader

This is the ghosted region representing the table column that is being dragged. It moves along the x-axis but is fixed in the y-axis.

dragHeaderLabelback to summary
private final Label dragHeaderLabel
fillerback to summary
private Region filler
flowback to summary
private final VirtualFlow<T extends IndexedCell<T>> flow
reorderingback to summary
private BooleanProperty reordering

Indicates if a reordering operation of a column is in progress. The value is true during a column reordering operation, and false otherwise. When a column is reordered (for example, by dragging its header), this property is updated automatically. Setting the value manually should be done when a subclass overrides the default reordering behavior. Calling setReorderingRegion(TableColumnHeader) before setting this property is required as well.

Since
12
reorderingRegionback to summary
private TableColumnHeader reorderingRegion
rootHeaderback to summary
private ReadOnlyObjectWrapper<NestedTableColumnHeader> rootHeader
scrollXback to summary
private double scrollX
tableColumnsListenerback to summary
private final ListChangeListener<E> tableColumnsListener
tablePaddingListenerback to summary
private InvalidationListener tablePaddingListener
tableSkinback to summary
pack-priv final TableViewSkinBase<?, ?, ?, ?, ?> tableSkin
tableWidthback to summary
private double tableWidth
tableWidthListenerback to summary
private InvalidationListener tableWidthListener
visibleColumnListenerback to summary
private InvalidationListener visibleColumnListener
visibleLeafColumnsListenerback to summary
private ListChangeListener<E> visibleLeafColumnsListener
weakColumnTextListenerback to summary
private final WeakInvalidationListener weakColumnTextListener
weakCornerPaddingListenerback to summary
private final WeakChangeListener<Boolean> weakCornerPaddingListener
weakTableColumnsListenerback to summary
private final WeakListChangeListener<E> weakTableColumnsListener
weakTablePaddingListenerback to summary
private final WeakInvalidationListener weakTablePaddingListener
weakTableWidthListenerback to summary
private final WeakInvalidationListener weakTableWidthListener
weakVisibleColumnListenerback to summary
private final WeakInvalidationListener weakVisibleColumnListener
weakVisibleLeafColumnsListenerback to summary
private final WeakListChangeListener<E> weakVisibleLeafColumnsListener

Constructor Detail

TableHeaderRowback to summary
public TableHeaderRow(final TableViewSkinBase<M, S, C extends Control, I extends IndexedCell<M>, TC extends TableColumnBase<S, ?>> skin)

Creates a new TableHeaderRow instance to visually represent the column header area of controls such as javafx.scene.control.TableView and javafx.scene.control.TreeTableView.

Parameters
skin:TableViewSkinBase<M, S, C extends Control, I extends IndexedCell<M>, TC extends TableColumnBase<S, ?>>

The skin used by the UI control.

Method Detail

computeMinHeightback to summary
protected double computeMinHeight(double width)

Overrides javafx.scene.layout.StackPane.computeMinHeight.

Doc from javafx.scene.layout.Region.computeMinHeight.

Computes the minimum height of this region. Returns the sum of the top and bottom insets by default. Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.

Annotations
@Override
computePrefHeightback to summary
protected double computePrefHeight(double width)

Overrides javafx.scene.layout.StackPane.computePrefHeight.

Doc from javafx.scene.layout.Region.computePrefHeight.

Computes the preferred height of this region for the given width; Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a HORIZONTAL content bias, then the width parameter can be ignored.

Annotations
@Override
computePrefWidthback to summary
protected double computePrefWidth(double height)

Overrides javafx.scene.layout.StackPane.computePrefWidth.

Doc from javafx.scene.layout.Region.computePrefWidth.

Computes the preferred width of this region for the given height. Region subclasses should override this method to return an appropriate value based on their content and layout strategy. If the subclass doesn't have a VERTICAL content bias, then the height parameter can be ignored.

Annotations
@Override
createMenuItemback to summary
private void createMenuItem(TableColumnBase<?, ?> col)
createRootHeaderback to summary
protected NestedTableColumnHeader createRootHeader()

Creates a new NestedTableColumnHeader instance. By default this method should not be overridden, but in some circumstances it makes sense (e.g. testing, or when extreme customization is desired).

Returns:NestedTableColumnHeader

A new NestedTableColumnHeader instance.

getColumnHeaderForback to summary
pack-priv TableColumnHeader getColumnHeaderFor(final TableColumnBase<?, ?> col)
getColumnHeaderForback to summary
private TableColumnHeader getColumnHeaderFor(final TableColumnBase<?, ?> col, TableColumnHeader currentHeader)
getColumnPopupMenuback to summary
pack-priv ContextMenu getColumnPopupMenu()
getCornerRegionback to summary
pack-priv Pane getCornerRegion()
getLeafColumnsback to summary
private List<TableColumnBase<?, ?>> getLeafColumns(TableColumnBase<?, ?> col)
getReorderingRegionback to summary
protected TableColumnHeader getReorderingRegion()

Returns the current TableColumnHeader being moved during reordering.

Returns:TableColumnHeader

the current TableColumnHeader being moved

Since
12
getRootHeaderback to summary
public final NestedTableColumnHeader getRootHeader()

Returns the root header for all columns. The root header is a NestedTableColumnHeader that contains the NestedTableColumnHeaders that represent each column. It spans the entire width of the TableView. This allows any developer overriding a TableColumnHeader to easily access the root header and all others TableColumnHeaders.

Implementation Note

This design enforces that column reordering occurs only within a single NestedTableColumnHeader and only at that level.

Returns:NestedTableColumnHeader

the root header

Since
12
getTextback to summary
private String getText(String text, TableColumnBase<S, T> col)
isColumnVisibleInHeaderback to summary
private boolean isColumnVisibleInHeader(TableColumnBase<S, T> col, List<E> columns)
isReorderingback to summary
public final boolean isReordering()
layoutChildrenback to summary
protected void layoutChildren()

Overrides javafx.scene.layout.StackPane.layoutChildren.

Doc from javafx.scene.Parent.layoutChildren.

Invoked during the layout pass to layout the children in this Parent. By default it will only set the size of managed, resizable content to their preferred sizes and does not do any node positioning.

Subclasses should override this function to layout content as needed.

Annotations
@Override
rebuildColumnMenuback to summary
private void rebuildColumnMenu()
removeback to summary
private void remove(TableColumnBase<?, ?> col)
reorderingPropertyback to summary
public final BooleanProperty reorderingProperty()
rootHeaderPropertyback to summary
private final ReadOnlyObjectProperty<NestedTableColumnHeader> rootHeaderProperty()
setDragHeaderXback to summary
pack-priv void setDragHeaderX(double dragHeaderX)
setReorderingback to summary
public final void setReordering(boolean value)
setReorderingColumnback to summary
pack-priv void setReorderingColumn(TableColumnBase<S, T> rc)
setReorderingRegionback to summary
protected void setReorderingRegion(TableColumnHeader reorderingRegion)

Sets the TableColumnHeader that is being moved during a reordering operation. This is automatically set by the TableColumnHeader when reordering starts. This method should only be called manually if the default reordering behavior is overridden. Calling setReordering(boolean) after the call is required.

Parameters
reorderingRegion:TableColumnHeader

the TableColumnHeader being reordered

Since
12
setRootHeaderback to summary
private final void setRootHeader(NestedTableColumnHeader value)
showColumnMenuback to summary
protected void showColumnMenu(MouseEvent mouseEvent)

Shows a menu containing all leaf columns as items. An item can be selected/deselected to make the corresponding column visible/invisible.

Implementation Note

This method can be overridden to create and show a custom menu.

Parameters
mouseEvent:MouseEvent

the MouseEvent which was generated when the table menu button was pressed

Since
21
updateCornerPaddingback to summary
private void updateCornerPadding()
updateScrollXback to summary
protected void updateScrollX()

Called whenever the value of the horizontal scrollbar changes in order to request layout changes, shifting the TableColumnHeaders.

For example, if custom components are added around a TableColumnHeader (such as icons above), they will also need to be shifted. When overriding, calling super() is required to shift the TableColumnHeaders, and it's up to the developer to notify its own custom components of this change.

Since
12
updateTableColumnListenersback to summary
private void updateTableColumnListeners(List<? extends TableColumnBase<?, ?>> added, List<? extends TableColumnBase<?, ?>> removed)
updateTableWidthback to summary
protected void updateTableWidth()

Updates the table width when a resize operation occurs. This method is called continuously when the control width is resizing in order to properly clip this TableHeaderRow. Overriding this method allows a subclass to customize the resizing behavior.

Normally, the TableHeaderRow is using the full space (TableView width), but in some cases that space may be reduced. For example, if a vertical header that will display the row number is introduced, the TableHeaderRow would need to be clipped a bit shorter in order not to overlap that vertical header. Calling super() first when overriding this method allows getClip() to compute the right width in order apply a transformation.

Since
12