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.
Modifier and Type | Class and Description |
---|---|
private static class |
Control.StyleableProperties
*
StyleSheet Handling *
*
|
Modifier and Type | Field and Description |
---|---|
private ObjectProperty<ContextMenu> |
contextMenu
The ContextMenu to show for this control.
|
private static EventHandler<ContextMenuEvent> |
contextMenuHandler
Handles context menu requests by popping up the menu.
|
private java.lang.String |
currentSkinClassName
Keeps a reference to the name of the class currently acting as the skin.
|
private ObjectProperty<Skin<?>> |
skin |
private SkinBase<?> |
skinBase
A private reference directly to the SkinBase instance that is used as the
Skin for this Control.
|
private StringProperty |
skinClassName |
private java.util.List<CssMetaData<? extends Styleable,?>> |
styleableProperties
*
Private fields *
*
|
private ObjectProperty<Tooltip> |
tooltip |
USE_COMPUTED_SIZE, USE_PREF_SIZE
BASELINE_OFFSET_SAME_AS_HEIGHT
Modifier | Constructor and Description |
---|---|
protected |
Control()
Create a new Control.
|
Modifier and Type | Method and Description |
---|---|
protected double |
computeMaxHeight(double width)
Computes the maximum allowable height of the Control, based on the provided
width.
|
protected double |
computeMaxWidth(double height)
Computes the maximum allowable width of the Control, based on the provided
height.
|
protected double |
computeMinHeight(double width)
Computes the minimum allowable height of the Control, based on the provided
width.
|
protected double |
computeMinWidth(double height)
Computes the minimum allowable width of the Control, based on the provided
height.
|
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.
|
protected double |
computePrefWidth(double height)
Computes the preferred width of this region for the given height.
|
ObjectProperty<ContextMenu> |
contextMenuProperty() |
protected Skin<?> |
createDefaultSkin()
Create a new instance of the default skin for this control.
|
void |
executeAccessibleAction(AccessibleAction action,
java.lang.Object... parameters)
This method is called by the assistive technology to request the action
indicated by the argument should be executed.
|
double |
getBaselineOffset()
Calculates the baseline offset based on the first managed child.
|
static java.util.List<CssMetaData<? extends Styleable,?>> |
getClassCssMetaData() |
ContextMenu |
getContextMenu() |
(package private) ObservableList<Node> |
getControlChildren()
*
Package API for SkinBase *
*
|
protected java.util.List<CssMetaData<? extends Styleable,?>> |
getControlCssMetaData() |
java.util.List<CssMetaData<? extends Styleable,?>> |
getCssMetaData()
This method returns a
List containing all CssMetaData for
both this Control (returned from getControlCssMetaData() and its
Skin , assuming the skin property is a
SkinBase . |
Skin<?> |
getSkin()
Returns the skin that renders this
Control |
private Node |
getSkinNode()
Gets the Skin's node, or returns null if there is no Skin.
|
Tooltip |
getTooltip() |
protected java.lang.Boolean |
impl_cssGetFocusTraversableInitialValue()
Deprecated.
|
protected void |
impl_processCSS(WritableValue<java.lang.Boolean> unused)
Deprecated.
This is an internal API that is not intended for use and will be removed in the next version
|
boolean |
isResizable()
Returns
true since all Controls are resizable. |
protected void |
layoutChildren()
Invoked during the layout pass to layout the children in this
Parent . |
private static java.lang.Class<?> |
loadClass(java.lang.String className,
java.lang.Object instance)
Utility for loading a class in a manner that will work with multiple
class loaders, as is typically found in OSGI modular applications.
|
(package private) static void |
loadSkinClass(Skinnable control,
java.lang.String skinClassName) |
java.lang.Object |
queryAccessibleAttribute(AccessibleAttribute attribute,
java.lang.Object... parameters)
*
Accessibility handling *
*
|
void |
setContextMenu(ContextMenu value) |
void |
setSkin(Skin<?> value)
Sets the skin that will render this
Control |
void |
setTooltip(Tooltip value) |
protected StringProperty |
skinClassNameProperty()
Deprecated.
|
ObjectProperty<Skin<?>> |
skinProperty()
Skin is responsible for rendering this
Control . |
ObjectProperty<Tooltip> |
tooltipProperty()
The ToolTip for this control.
|
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, impl_computeContains, impl_computeGeomBounds, impl_computeLayoutBounds, impl_createPeer, impl_notifyLayoutBoundsChanged, impl_pickNodeLocal, impl_updatePeer, 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
getChildren, getChildrenUnmodifiable, getImpl_traversalEngine, getManagedChildren, getStylesheets, impl_getAllParentStylesheets, impl_processMXNode, impl_traversalEngineProperty, isNeedsLayout, layout, lookup, needsLayoutProperty, requestLayout, requestParentLayout, setImpl_traversalEngine, setNeedsLayout, updateBounds
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, containsBounds, 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, impl_clearDirty, impl_computeIntersects, impl_cssGetCursorInitialValue, impl_findStyles, impl_geomChanged, impl_getLeafTransform, impl_getMatchingStyles, impl_getPeer, impl_getPivotX, impl_getPivotY, impl_getPivotZ, impl_getStyleMap, impl_hasTransforms, impl_intersects, impl_intersectsBounds, impl_isDirty, impl_isDirtyEmpty, impl_isShowMnemonics, impl_isTreeVisible, impl_layoutBoundsChanged, impl_markDirty, impl_pickNode, impl_processCSS, impl_reapplyCSS, impl_setShowMnemonics, impl_setStyleMap, impl_showMnemonicsProperty, impl_syncPeer, impl_transformsChanged, impl_traverse, impl_treeVisibleProperty, 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
private java.util.List<CssMetaData<? extends Styleable,?>> styleableProperties
private SkinBase<?> skinBase
private static final EventHandler<ContextMenuEvent> contextMenuHandler
private ObjectProperty<Skin<?>> skin
private ObjectProperty<Tooltip> tooltip
private ObjectProperty<ContextMenu> contextMenu
private java.lang.String currentSkinClassName
private StringProperty skinClassName
private static java.lang.Class<?> loadClass(java.lang.String className, java.lang.Object instance) throws java.lang.ClassNotFoundException
className
- The name of the class we want to loadinstance
- An optional instance used to help find the class to loadjava.lang.ClassNotFoundException
- If the class cannot be found using any technique.public final ObjectProperty<Skin<?>> skinProperty()
Control
. From the
perspective of the Control
, the Skin
is a black box.
It listens and responds to changes in state in a Control
.
There is a one-to-one relationship between a Control
and its
Skin
. Every Skin
maintains a back reference to the
Control
via the Skin.getSkinnable()
method.
A skin may be null.
skinProperty
in interface Skinnable
public final void setSkin(Skin<?> value)
Skinnable
Control
public final Skin<?> getSkin()
Skinnable
Control
public final ObjectProperty<Tooltip> tooltipProperty()
public final void setTooltip(Tooltip value)
public final Tooltip getTooltip()
public final ObjectProperty<ContextMenu> contextMenuProperty()
public final void setContextMenu(ContextMenu value)
public final ContextMenu getContextMenu()
public boolean isResizable()
true
since all Controls are resizable.isResizable
in class Region
Node.getContentBias()
,
Node.minWidth(double)
,
Node.minHeight(double)
,
Node.prefWidth(double)
,
Node.prefHeight(double)
,
Node.maxWidth(double)
,
Node.maxHeight(double)
,
Node.resize(double, double)
,
Node.getLayoutBounds()
protected double computeMinWidth(double height)
Node.minWidth(double)
method
of the Skin
. If the Skin is null, the returned value is 0.computeMinWidth
in class Region
height
- The height of the Control, in case this value might dictate
the minimum width.protected double computeMinHeight(double width)
Node.minHeight(double)
method
of the Skin
. If the Skin is null, the returned value is 0.computeMinHeight
in class Region
width
- The width of the Control, in case this value might dictate
the minimum height.protected double computeMaxWidth(double height)
Node.maxWidth(double)
method
of the Skin
. If the Skin is null, the returned value is 0.computeMaxWidth
in class Region
height
- The height of the Control, in case this value might dictate
the maximum width.protected double computeMaxHeight(double width)
Node.maxHeight(double)
method
of the Skin
. If the Skin is null, the returned value is 0.computeMaxHeight
in class Region
width
- The width of the Control, in case this value might dictate
the maximum height.protected double computePrefWidth(double height)
computePrefWidth
in class Region
height
- the height that should be used if preferred width depends
on itprotected double computePrefHeight(double width)
computePrefHeight
in class Region
width
- the width that should be used if preferred height depends
on itpublic double getBaselineOffset()
Node.getBaselineOffset()
.getBaselineOffset
in class Parent
protected void layoutChildren()
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.
layoutChildren
in class Parent
protected Skin<?> createDefaultSkin()
-fx-skin
or set explicitly in a sub-class with setSkin(...)
.ObservableList<Node> getControlChildren()
private Node getSkinNode()
@Deprecated protected StringProperty skinClassNameProperty()
static void loadSkinClass(Skinnable control, java.lang.String skinClassName)
public static java.util.List<CssMetaData<? extends Styleable,?>> getClassCssMetaData()
public final java.util.List<CssMetaData<? extends Styleable,?>> getCssMetaData()
List
containing all CssMetaData
for
both this Control (returned from getControlCssMetaData()
and its
Skin
, assuming the skin property
is a
SkinBase
.
Developers who wish to provide custom CssMetaData are therefore
encouraged to override getControlCssMetaData()
or
SkinBase.getCssMetaData()
, depending on where the CssMetaData
resides.
getCssMetaData
in interface Styleable
getCssMetaData
in class Region
protected java.util.List<CssMetaData<? extends Styleable,?>> getControlCssMetaData()
@Deprecated protected void impl_processCSS(WritableValue<java.lang.Boolean> unused)
Node
super.impl_processCSS()
to ensure that
this Node's CSS state is properly updated.
Note that the difference between this method and Node.impl_processCSS(boolean)
is that this method
updates styles for this node on down; whereas, impl_processCSS(boolean)
invokes
Node.applyCss()
which will look for the top-most ancestor that needs CSS update and apply styles
from that node on down.
The WritableValue<Boolean> parameter is no longer used.impl_processCSS
in class Parent
@Deprecated protected java.lang.Boolean impl_cssGetFocusTraversableInitialValue()
impl_cssGetFocusTraversableInitialValue
in class Node
public java.lang.Object queryAccessibleAttribute(AccessibleAttribute attribute, java.lang.Object... parameters)
queryAccessibleAttribute
in class Parent
attribute
- the requested attributeparameters
- optional list of parametersAccessibleAttribute
public void executeAccessibleAction(AccessibleAction action, java.lang.Object... parameters)
Node
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.
executeAccessibleAction
in class Node
action
- the action to executeparameters
- optional list of parametersAccessibleAction