Class Control
- javafx.scene.Node
-
- javafx.scene.Parent
-
- javafx.scene.layout.Region
-
- javafx.scene.control.Control
All Implemented Interfaces:
Direct Known Subclasses:
Accordion, ButtonBar, ChoiceBox, ComboBoxBase, HTMLEditor, Labeled, ListView, MenuBar, Pagination, ProgressIndicator, ScrollBar, ScrollPane, Separator, Slider, Spinner, SplitPane, TableView, TabPane, TextInputControl, ToolBar, TreeTableView, TreeView
public abstract class Control extends Region implements Skinnable
Additionally, controls support explicit skinning to make it easy to leverage the functionality of a control while customizing its appearance.
See specific Control subclasses for information on how to use individual types of controls.
Most controls have their focusTraversable property set to true by default, however read-only controls such as Label and ProgressIndicator, and some controls that are containers ScrollPane and ToolBar do not. Consult individual control documentation for details.
Since:
JavaFX 2.0
-
Property Summary
All MethodsInstance MethodsConcrete Methods Type Property and Description ObjectProperty<ContextMenu>contextMenuThe ContextMenu to show for this control.ObjectProperty<Skin<?>>skinSkin is responsible for rendering thisControl.ObjectProperty<Tooltip>tooltipThe ToolTip for this control.-
Properties inherited from class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
-
Properties inherited from class javafx.scene.Parent
needsLayout
-
Properties inherited from class javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, visible
-
-
Field Summary
-
Fields inherited from class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZE
-
Fields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT
-
-
Constructor Summary
Constructors Modifier Constructor and Description protectedControl()Create a new Control.
-
Method Summary
All MethodsStatic MethodsInstance MethodsConcrete Methods Modifier and Type Method and Description protected doublecomputeMaxHeight(double width)Computes the maximum allowable height of the Control, based on the provided width.protected doublecomputeMaxWidth(double height)Computes the maximum allowable width of the Control, based on the provided height.protected doublecomputeMinHeight(double width)Computes the minimum allowable height of the Control, based on the provided width.protected doublecomputeMinWidth(double height)Computes the minimum allowable width of the Control, based on the provided height.protected doublecomputePrefHeight(double width)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 doublecomputePrefWidth(double height)Computes the preferred width of this region for the given height.ObjectProperty<ContextMenu>contextMenuProperty()The ContextMenu to show for this control.protected Skin<?>createDefaultSkin()Create a new instance of the default skin for this control.voidexecuteAccessibleAction(AccessibleAction action, Object... parameters)This method is called by the assistive technology to request the action indicated by the argument should be executed.doublegetBaselineOffset()Calculates the baseline offset based on the first managed child.static List<CssMetaData<? extends Styleable,?>>getClassCssMetaData()ContextMenugetContextMenu()Gets the value of the property contextMenu.protected List<CssMetaData<? extends Styleable,?>>getControlCssMetaData()List<CssMetaData<? extends Styleable,?>>getCssMetaData()This method returns aListcontaining allCssMetaDatafor both this Control (returned fromgetControlCssMetaData()and itsSkin, assuming theskin propertyis aSkinBase.Skin<?>getSkin()Gets the value of the property skin.TooltipgetTooltip()Gets the value of the property tooltip.booleanisResizable()Returnstruesince all Controls are resizable.protected voidlayoutChildren()Invoked during the layout pass to layout the children in thisParent.ObjectqueryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)* Accessibility handling * *voidsetContextMenu(ContextMenu value)Sets the value of the property contextMenu.voidsetSkin(Skin<?> value)Sets the value of the property skin.voidsetTooltip(Tooltip value)Sets the value of the property tooltip.ObjectProperty<Skin<?>>skinProperty()Skin is responsible for rendering thisControl.ObjectProperty<Tooltip>tooltipProperty()The ToolTip for this control.-
Methods inherited from class javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapSize, snapSpace, snapToPixelProperty, widthProperty
-
Methods inherited from class javafx.scene.Parent
getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setNeedsLayout, updateBounds
-
Methods inherited from class javafx.scene.Node
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, visibleProperty
-
-
Property Detail
-
skin
public final ObjectProperty<Skin<?>> skinProperty
Skin is responsible for rendering thisControl. From the perspective of theControl, theSkinis a black box. It listens and responds to changes in state in aControl.There is a one-to-one relationship between a
Controland itsSkin. EverySkinmaintains a back reference to theControlvia theSkin.getSkinnable()method.A skin may be null.
Specified by:
skinPropertyin interfaceSkinnableSee Also:
-
tooltip
public final ObjectProperty<Tooltip> tooltipProperty
The ToolTip for this control.See Also:
-
contextMenu
public final ObjectProperty<ContextMenu> contextMenuProperty
The ContextMenu to show for this control.See Also:
-
-
Constructor Detail
-
Control
protected Control()
Create a new Control.
-
-
Method Detail
-
skinProperty
public final ObjectProperty<Skin<?>> skinProperty()
Skin is responsible for rendering thisControl. From the perspective of theControl, theSkinis a black box. It listens and responds to changes in state in aControl.There is a one-to-one relationship between a
Controland itsSkin. EverySkinmaintains a back reference to theControlvia theSkin.getSkinnable()method.A skin may be null.
Specified by:
skinPropertyin interfaceSkinnableSee Also:
-
setSkin
public final void setSkin(Skin<?> value)
Sets the value of the property skin.Property description:
Skin is responsible for rendering this
Control. From the perspective of theControl, theSkinis a black box. It listens and responds to changes in state in aControl.There is a one-to-one relationship between a
Controland itsSkin. EverySkinmaintains a back reference to theControlvia theSkin.getSkinnable()method.A skin may be null.
-
getSkin
public final Skin<?> getSkin()
Gets the value of the property skin.Property description:
Skin is responsible for rendering this
Control. From the perspective of theControl, theSkinis a black box. It listens and responds to changes in state in aControl.There is a one-to-one relationship between a
Controland itsSkin. EverySkinmaintains a back reference to theControlvia theSkin.getSkinnable()method.A skin may be null.
-
tooltipProperty
public final ObjectProperty<Tooltip> tooltipProperty()
The ToolTip for this control.See Also:
-
setTooltip
public final void setTooltip(Tooltip value)
Sets the value of the property tooltip.Property description:
The ToolTip for this control.
-
getTooltip
public final Tooltip getTooltip()
Gets the value of the property tooltip.Property description:
The ToolTip for this control.
-
contextMenuProperty
public final ObjectProperty<ContextMenu> contextMenuProperty()
The ContextMenu to show for this control.See Also:
-
setContextMenu
public final void setContextMenu(ContextMenu value)
Sets the value of the property contextMenu.Property description:
The ContextMenu to show for this control.
-
getContextMenu
public final ContextMenu getContextMenu()
Gets the value of the property contextMenu.Property description:
The ContextMenu to show for this control.
-
isResizable
public boolean isResizable()
Returnstruesince all Controls are resizable.Overrides:
isResizablein classRegionReturns:
whether this node can be resized by its parent during layout
-
computeMinWidth
protected double computeMinWidth(double height)
Computes the minimum allowable width of the Control, based on the provided height. The minimum width is not calculated within the Control, instead the calculation is delegated to theNode.minWidth(double)method of theSkin. If the Skin is null, the returned value is 0.Overrides:
computeMinWidthin classRegionParameters:
height- The height of the Control, in case this value might dictate the minimum width.Returns:
A double representing the minimum width of this control.
-
computeMinHeight
protected double computeMinHeight(double width)
Computes the minimum allowable height of the Control, based on the provided width. The minimum height is not calculated within the Control, instead the calculation is delegated to theNode.minHeight(double)method of theSkin. If the Skin is null, the returned value is 0.Overrides:
computeMinHeightin classRegionParameters:
width- The width of the Control, in case this value might dictate the minimum height.Returns:
A double representing the minimum height of this control.
-
computeMaxWidth
protected double computeMaxWidth(double height)
Computes the maximum allowable width of the Control, based on the provided height. The maximum width is not calculated within the Control, instead the calculation is delegated to theNode.maxWidth(double)method of theSkin. If the Skin is null, the returned value is 0.Overrides:
computeMaxWidthin classRegionParameters:
height- The height of the Control, in case this value might dictate the maximum width.Returns:
A double representing the maximum width of this control.
-
computeMaxHeight
protected double computeMaxHeight(double width)
Computes the maximum allowable height of the Control, based on the provided width. The maximum height is not calculated within the Control, instead the calculation is delegated to theNode.maxHeight(double)method of theSkin. If the Skin is null, the returned value is 0.Overrides:
computeMaxHeightin classRegionParameters:
width- The width of the Control, in case this value might dictate the maximum height.Returns:
A double representing the maximum height of this control.
-
computePrefWidth
protected double computePrefWidth(double height)
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.Overrides:
computePrefWidthin classRegionParameters:
height- the height that should be used if preferred width depends on itReturns:
the computed preferred width for this region
-
computePrefHeight
protected double computePrefHeight(double width)
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.Overrides:
computePrefHeightin classRegionParameters:
width- the width that should be used if preferred height depends on itReturns:
the computed preferred height for this region
-
getBaselineOffset
public double getBaselineOffset()
Calculates the baseline offset based on the first managed child. If there is no such child, returnsNode.getBaselineOffset().Overrides:
getBaselineOffsetin classParentReturns:
baseline offset
-
layoutChildren
protected void layoutChildren()
Invoked during the layout pass to layout the children in thisParent. 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.
Overrides:
layoutChildrenin classParent
-
createDefaultSkin
protected Skin<?> createDefaultSkin()
Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS-fx-skinor set explicitly in a sub-class withsetSkin(...).Returns:
new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.
Since:
JavaFX 8.0
-
getClassCssMetaData
public static List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
Returns:
The CssMetaData associated with this class, which may include the CssMetaData of its super classes.
Since:
JavaFX 8.0
-
getCssMetaData
public final List<CssMetaData<? extends Styleable,?>> getCssMetaData()
This method returns aListcontaining allCssMetaDatafor both this Control (returned fromgetControlCssMetaData()and itsSkin, assuming theskin propertyis aSkinBase.Developers who wish to provide custom CssMetaData are therefore encouraged to override
getControlCssMetaData()orSkinBase.getCssMetaData(), depending on where the CssMetaData resides.Specified by:
getCssMetaDatain interfaceStyleableOverrides:
getCssMetaDatain classRegionReturns:
The CssMetaData associated with this node, which may include the CssMetaData of its super classes.
Since:
JavaFX 8.0
-
getControlCssMetaData
protected List<CssMetaData<? extends Styleable,?>> getControlCssMetaData()
Returns:
unmodifiable list of the controls css styleable properties
Since:
JavaFX 8.0
-
queryAccessibleAttribute
public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)* Accessibility handling * *Overrides:
queryAccessibleAttributein classParentParameters:
attribute- the requested attributeReturns:
the value for the requested attribute
See Also:
-
executeAccessibleAction
public void executeAccessibleAction(AccessibleAction action, Object... parameters)Description copied from class:NodeThis method is called by the assistive technology to request the action indicated by the argument should be executed.This method is commonly overridden by subclasses to implement action that are required for a specific role.
If a particular action is not handled, the super class implementation must be called.Overrides:
executeAccessibleActionin classNodeParameters:
action- the action to executeSee Also:
-
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.