Top Description Inners Fields Constructors Methods
javafx.scene.control

public Class ScrollPane

extends Control
Class Inheritance
Annotations
@DefaultProperty:content
Imports
java.util.ArrayList, .Collections, .List, javafx.beans.DefaultProperty, javafx.beans.property.BooleanProperty, .DoubleProperty, .ObjectProperty, .SimpleDoubleProperty, .SimpleObjectProperty, javafx.beans.value.WritableValue, javafx.css.CssMetaData, .PseudoClass, .StyleableBooleanProperty, .StyleableObjectProperty, .StyleableProperty, .Styleable, javafx.geometry.BoundingBox, .Bounds, javafx.scene.AccessibleAttribute, .AccessibleRole, .Node, javafx.css.converter.BooleanConverter, .EnumConverter, javafx.scene.control.skin.ScrollPaneSkin

A Control that provides a scrolled, clipped viewport of its contents. It allows the user to scroll the content around either directly (panning) or by using scroll bars. The ScrollPane allows specification of the scroll bar policy, which determines when scroll bars are displayed: always, never, or only when they are needed. The scroll bar policy can be specified independently for the horizontal and vertical scroll bars.

The ScrollPane allows the application to set the current, minimum, and maximum values for positioning the contents in the horizontal and vertical directions. These values are mapped proportionally onto the layoutBounds of the contained node.

ScrollPane layout calculations are based on the layoutBounds rather than the boundsInParent (visual bounds) of the scroll node. If an application wants the scrolling to be based on the visual bounds of the node (for scaled content etc.), it needs to wrap the scroll node in a Group.

ScrollPane sets focusTraversable to false.

ScrollPane only acts on key presses when it has the focus (isFocused() returns true) and won't respond to key events that bubble up from a focused child control.

This example creates a ScrollPane, which contains a Rectangle:

 Rectangle rect = new Rectangle(200, 200, Color.RED);
ScrollPane s1 = new ScrollPane();
s1.setPrefSize(120, 120);
s1.setContent(rect);
Image of the ScrollPane control
Since
JavaFX 2.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
ScrollPane.ScrollBarPolicy

An enumeration denoting the policy to be used by a scrollable Control in deciding whether to show a scroll bar.

private static class

Field Summary

Modifier and TypeField and Description
private ObjectProperty<Node>
content

The node used as the content of this ScrollPane.

private static final String
DEFAULT_STYLE_CLASS

Initialize the style class to 'scroll-view'.

private static final PseudoClass
private static final PseudoClass
private BooleanProperty
fitToHeight

If true and if the contained node is a Resizable, then the node will be kept resized to match the height of the ScrollPane's viewport.

private BooleanProperty
fitToWidth

If true and if the contained node is a Resizable, then the node will be kept resized to match the width of the ScrollPane's viewport.

private ObjectProperty<ScrollPane.ScrollBarPolicy>
hbarPolicy

Specifies the policy for showing the horizontal scroll bar.

private DoubleProperty
hmax

The maximum allowable hvalue for this ScrollPane.

private DoubleProperty
hmin

The minimum allowable hvalue for this ScrollPane.

private DoubleProperty
hvalue

The current horizontal scroll position of the ScrollPane.

private DoubleProperty
minViewportHeight

Specify the minimum height of the ScrollPane Viewport.

private DoubleProperty
minViewportWidth

Specify the minimum width of the ScrollPane Viewport.

private BooleanProperty
pannable

Specifies whether the user should be able to pan the viewport by using the mouse.

private static final PseudoClass
private DoubleProperty
prefViewportHeight

Specify the preferred height of the ScrollPane Viewport.

private DoubleProperty
prefViewportWidth

Specify the preferred width of the ScrollPane Viewport.

private ObjectProperty<ScrollPane.ScrollBarPolicy>
vbarPolicy

Specifies the policy for showing the vertical scroll bar.

private ObjectProperty<Bounds>
viewportBounds

The actual Bounds of the ScrollPane Viewport.

private DoubleProperty
vmax

The maximum allowable vvalue for this ScrollPane.

private DoubleProperty
vmin

The minimum allowable vvalue for this ScrollPane.

private DoubleProperty
vvalue

The current vertical scroll position of the ScrollPane.

Constructor Summary

AccessConstructor and Description
public
ScrollPane()

Creates a new ScrollPane.

public
ScrollPane(Node
the initial content for the ScrollPane
content
)

Creates a new ScrollPane.

Method Summary

Modifier and TypeMethod and Description
public final ObjectProperty<Node>
protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

public final BooleanProperty
public final BooleanProperty
public static List<CssMetaData<? extends Styleable, ?>>

Returns:

the CssMetaData
getClassCssMetaData
()

Hides javafx.scene.control.Control.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

public final Node
public List<CssMetaData<? extends Styleable, ?>>
getControlCssMetaData()

Overrides javafx.scene.control.Control.getControlCssMetaData.

Gets the unmodifiable list of the control's CSS-styleable properties.

public final ScrollPane.ScrollBarPolicy
public final double
public final double
public final double
protected Boolean
getInitialFocusTraversable()

Overrides javafx.scene.control.Control.getInitialFocusTraversable.

Returns the initial focus traversable state of this control, for use by the JavaFX CSS engine to correctly set its initial value.

public final double
public final double
public final double
public final double
public final ScrollPane.ScrollBarPolicy
public final Bounds
public final double
public final double
public final double
public final ObjectProperty<ScrollPane.ScrollBarPolicy>
public final DoubleProperty
public final DoubleProperty
public final DoubleProperty
public final boolean
public final boolean
public final boolean
public final DoubleProperty
public final DoubleProperty
public final BooleanProperty
public final DoubleProperty
public final DoubleProperty
public Object
queryAccessibleAttribute(AccessibleAttribute
the requested attribute
attribute
,
Object...
optional list of parameters
parameters
)

Overrides javafx.scene.control.Control.queryAccessibleAttribute.

This method is called by the assistive technology to request the value for an attribute.

public final void
public final void
setFitToHeight(boolean value)

public final void
setFitToWidth(boolean value)

public final void
public final void
setHmax(double value)

public final void
setHmin(double value)

public final void
setHvalue(double value)

public final void
setMinViewportHeight(double value)

public final void
setMinViewportWidth(double value)

public final void
setPannable(boolean value)

public final void
setPrefViewportHeight(double value)

public final void
setPrefViewportWidth(double value)

public final void
public final void
public final void
setVmax(double value)

public final void
setVmin(double value)

public final void
setVvalue(double value)

public final ObjectProperty<ScrollPane.ScrollBarPolicy>
public final ObjectProperty<Bounds>
public final DoubleProperty
public final DoubleProperty
public final DoubleProperty
Inherited from javafx.scene.control.Control:
computeMaxHeightcomputeMaxWidthcomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthcontextMenuPropertyexecuteAccessibleActiongetBaselineOffsetgetContextMenugetControlChildrengetCssMetaDatagetSkingetTooltipisResizablelayoutChildrenloadSkinClasssetContextMenusetSkinsetTooltipskinClassNamePropertyskinPropertytooltipProperty

Field Detail

contentback to summary
private ObjectProperty<Node> content

The node used as the content of this ScrollPane.

DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS

Initialize the style class to 'scroll-view'. This is the selector class from which CSS can be used to style this control.

FIT_TO_HEIGHT_PSEUDOCLASS_STATEback to summary
private static final PseudoClass FIT_TO_HEIGHT_PSEUDOCLASS_STATE
FIT_TO_WIDTH_PSEUDOCLASS_STATEback to summary
private static final PseudoClass FIT_TO_WIDTH_PSEUDOCLASS_STATE
fitToHeightback to summary
private BooleanProperty fitToHeight

If true and if the contained node is a Resizable, then the node will be kept resized to match the height of the ScrollPane's viewport. If the contained node is not a Resizable, this value is ignored.

fitToWidthback to summary
private BooleanProperty fitToWidth

If true and if the contained node is a Resizable, then the node will be kept resized to match the width of the ScrollPane's viewport. If the contained node is not a Resizable, this value is ignored.

hbarPolicyback to summary
private ObjectProperty<ScrollPane.ScrollBarPolicy> hbarPolicy

Specifies the policy for showing the horizontal scroll bar.

hmaxback to summary
private DoubleProperty hmax

The maximum allowable hvalue for this ScrollPane. Default value is 1.

hminback to summary
private DoubleProperty hmin

The minimum allowable hvalue for this ScrollPane. Default value is 0.

hvalueback to summary
private DoubleProperty hvalue

The current horizontal scroll position of the ScrollPane. This value may be set by the application to scroll the view programmatically. The ScrollPane will update this value whenever the viewport is scrolled or panned by the user. This value must always be within the range of hmin to hmax. When hvalue equals hmin, the contained node is positioned so that its layoutBounds minX is visible. When hvalue equals hmax, the contained node is positioned so that its layoutBounds maxX is visible. When hvalue is between hmin and hmax, the contained node is positioned proportionally between layoutBounds minX and layoutBounds maxX.

minViewportHeightback to summary
private DoubleProperty minViewportHeight

Specify the minimum height of the ScrollPane Viewport. This is the height that will be available to the content node.

Since
JavaFX 8u40
See Also
prefViewportHeightProperty()
minViewportWidthback to summary
private DoubleProperty minViewportWidth

Specify the minimum width of the ScrollPane Viewport. This is the width that will be available to the content node.

Since
JavaFX 8u40
See Also
prefViewportWidthProperty()
pannableback to summary
private BooleanProperty pannable

Specifies whether the user should be able to pan the viewport by using the mouse. If mouse events reach the ScrollPane (that is, if mouse events are not blocked by the contained node or one of its children) then pannable is consulted to determine if the events should be used for panning.

PANNABLE_PSEUDOCLASS_STATEback to summary
private static final PseudoClass PANNABLE_PSEUDOCLASS_STATE
prefViewportHeightback to summary
private DoubleProperty prefViewportHeight

Specify the preferred height of the ScrollPane Viewport. This is the height that will be available to the content node. The overall height of the ScrollPane is the ViewportHeight + padding

prefViewportWidthback to summary
private DoubleProperty prefViewportWidth

Specify the preferred width of the ScrollPane Viewport. This is the width that will be available to the content node. The overall width of the ScrollPane is the ViewportWidth + padding

vbarPolicyback to summary
private ObjectProperty<ScrollPane.ScrollBarPolicy> vbarPolicy

Specifies the policy for showing the vertical scroll bar.

viewportBoundsback to summary
private ObjectProperty<Bounds> viewportBounds

The actual Bounds of the ScrollPane Viewport. This is the Bounds of the content node.

vmaxback to summary
private DoubleProperty vmax

The maximum allowable vvalue for this ScrollPane. Default value is 1.

vminback to summary
private DoubleProperty vmin

The minimum allowable vvalue for this ScrollPane. Default value is 0.

vvalueback to summary
private DoubleProperty vvalue

The current vertical scroll position of the ScrollPane. This value may be set by the application to scroll the view programmatically. The ScrollPane will update this value whenever the viewport is scrolled or panned by the user. This value must always be within the range of vmin to vmax. When vvalue equals vmin, the contained node is positioned so that its layoutBounds minY is visible. When vvalue equals vmax, the contained node is positioned so that its layoutBounds maxY is visible. When vvalue is between vmin and vmax, the contained node is positioned proportionally between layoutBounds minY and layoutBounds maxY.

Constructor Detail

ScrollPaneback to summary
public ScrollPane()

Creates a new ScrollPane.

ScrollPaneback to summary
public ScrollPane(Node content)

Creates a new ScrollPane.

Parameters
content:Node

the initial content for the ScrollPane

Since
JavaFX 8.0

Method Detail

contentPropertyback to summary
public final ObjectProperty<Node> contentProperty()
createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.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-skin or set explicitly in a sub-class with setSkin(...).

Returns:Skin<?>

new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.

Annotations
@Override
fitToHeightPropertyback to summary
public final BooleanProperty fitToHeightProperty()
fitToWidthPropertyback to summary
public final BooleanProperty fitToWidthProperty()
getClassCssMetaDataback to summary
public static List<CssMetaData<? extends Styleable, ?>> getClassCssMetaData()

Hides javafx.scene.control.Control.getClassCssMetaData.

Gets the CssMetaData associated with this class, which may include the CssMetaData of its superclasses.

Returns:List<CssMetaData<? extends Styleable, ?>>

the CssMetaData

Since
JavaFX 8.0
getContentback to summary
public final Node getContent()
getControlCssMetaDataback to summary
public List<CssMetaData<? extends Styleable, ?>> getControlCssMetaData()

Overrides javafx.scene.control.Control.getControlCssMetaData.

Doc from javafx.scene.control.Control.getControlCssMetaData.

Gets the unmodifiable list of the control's CSS-styleable properties.

Returns:List<CssMetaData<? extends Styleable, ?>>

the unmodifiable list of the control's CSS-styleable properties

Annotations
@Override
Since
JavaFX 8.0
getHbarPolicyback to summary
public final ScrollPane.ScrollBarPolicy getHbarPolicy()
getHmaxback to summary
public final double getHmax()
getHminback to summary
public final double getHmin()
getHvalueback to summary
public final double getHvalue()
getInitialFocusTraversableback to summary
protected Boolean getInitialFocusTraversable()

Overrides javafx.scene.control.Control.getInitialFocusTraversable.

Returns the initial focus traversable state of this control, for use by the JavaFX CSS engine to correctly set its initial value. This method is overridden as by default UI controls have focus traversable set to true, but that is not appropriate for this control.

Returns:Boolean

Doc from javafx.scene.control.Control.getInitialFocusTraversable.

the initial focus traversable state of this control

Annotations
@Override
Since
9
getMinViewportHeightback to summary
public final double getMinViewportHeight()
getMinViewportWidthback to summary
public final double getMinViewportWidth()
getPrefViewportHeightback to summary
public final double getPrefViewportHeight()
getPrefViewportWidthback to summary
public final double getPrefViewportWidth()
getVbarPolicyback to summary
public final ScrollPane.ScrollBarPolicy getVbarPolicy()
getViewportBoundsback to summary
public final Bounds getViewportBounds()
getVmaxback to summary
public final double getVmax()
getVminback to summary
public final double getVmin()
getVvalueback to summary
public final double getVvalue()
hbarPolicyPropertyback to summary
public final ObjectProperty<ScrollPane.ScrollBarPolicy> hbarPolicyProperty()
hmaxPropertyback to summary
public final DoubleProperty hmaxProperty()
hminPropertyback to summary
public final DoubleProperty hminProperty()
hvaluePropertyback to summary
public final DoubleProperty hvalueProperty()
isFitToHeightback to summary
public final boolean isFitToHeight()
isFitToWidthback to summary
public final boolean isFitToWidth()
isPannableback to summary
public final boolean isPannable()
minViewportHeightPropertyback to summary
public final DoubleProperty minViewportHeightProperty()
minViewportWidthPropertyback to summary
public final DoubleProperty minViewportWidthProperty()
pannablePropertyback to summary
public final BooleanProperty pannableProperty()
prefViewportHeightPropertyback to summary
public final DoubleProperty prefViewportHeightProperty()
prefViewportWidthPropertyback to summary
public final DoubleProperty prefViewportWidthProperty()
queryAccessibleAttributeback to summary
public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)

Overrides javafx.scene.control.Control.queryAccessibleAttribute.

Doc from javafx.scene.control.Control.queryAccessibleAttribute.

This method is called by the assistive technology to request the value for an attribute.

This method is commonly overridden by subclasses to implement attributes that are required for a specific role.
If a particular attribute is not handled, the superclass implementation must be called.

Parameters
attribute:AccessibleAttribute

Doc from javafx.scene.Node.queryAccessibleAttribute.

the requested attribute

parameters:Object[]

Doc from javafx.scene.Node.queryAccessibleAttribute.

optional list of parameters

Returns:Object

Doc from javafx.scene.Node.queryAccessibleAttribute.

the value for the requested attribute

Annotations
@Override
setContentback to summary
public final void setContent(Node value)
setFitToHeightback to summary
public final void setFitToHeight(boolean value)
setFitToWidthback to summary
public final void setFitToWidth(boolean value)
setHbarPolicyback to summary
public final void setHbarPolicy(ScrollPane.ScrollBarPolicy value)
setHmaxback to summary
public final void setHmax(double value)
setHminback to summary
public final void setHmin(double value)
setHvalueback to summary
public final void setHvalue(double value)
setMinViewportHeightback to summary
public final void setMinViewportHeight(double value)
setMinViewportWidthback to summary
public final void setMinViewportWidth(double value)
setPannableback to summary
public final void setPannable(boolean value)
setPrefViewportHeightback to summary
public final void setPrefViewportHeight(double value)
setPrefViewportWidthback to summary
public final void setPrefViewportWidth(double value)
setVbarPolicyback to summary
public final void setVbarPolicy(ScrollPane.ScrollBarPolicy value)
setViewportBoundsback to summary
public final void setViewportBounds(Bounds value)
setVmaxback to summary
public final void setVmax(double value)
setVminback to summary
public final void setVmin(double value)
setVvalueback to summary
public final void setVvalue(double value)
vbarPolicyPropertyback to summary
public final ObjectProperty<ScrollPane.ScrollBarPolicy> vbarPolicyProperty()
viewportBoundsPropertyback to summary
public final ObjectProperty<Bounds> viewportBoundsProperty()
vmaxPropertyback to summary
public final DoubleProperty vmaxProperty()
vminPropertyback to summary
public final DoubleProperty vminProperty()
vvaluePropertyback to summary
public final DoubleProperty vvalueProperty()
javafx.scene.control back to summary

public final Enum ScrollPane.ScrollBarPolicy

extends Enum<ScrollPane.ScrollBarPolicy>
Class Inheritance

An enumeration denoting the policy to be used by a scrollable Control in deciding whether to show a scroll bar.
Since
JavaFX 2.0

Field Summary

Modifier and TypeField and Description
public static final ScrollPane.ScrollBarPolicy
ALWAYS

Indicates that a scroll bar should always be shown.

public static final ScrollPane.ScrollBarPolicy
AS_NEEDED

Indicates that a scroll bar should be shown when required.

public static final ScrollPane.ScrollBarPolicy
NEVER

Indicates that a scroll bar should never be shown.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ScrollPane.ScrollBarPolicy
public static ScrollPane.ScrollBarPolicy[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ALWAYSback to summary
public static final ScrollPane.ScrollBarPolicy ALWAYS

Indicates that a scroll bar should always be shown.

AS_NEEDEDback to summary
public static final ScrollPane.ScrollBarPolicy AS_NEEDED

Indicates that a scroll bar should be shown when required.

NEVERback to summary
public static final ScrollPane.ScrollBarPolicy NEVER

Indicates that a scroll bar should never be shown.

Constructor Detail

ScrollBarPolicyback to summary
private ScrollBarPolicy()

Method Detail

valueOfback to summary
public static ScrollPane.ScrollBarPolicy valueOf(String name)
valuesback to summary
public static ScrollPane.ScrollBarPolicy[] values()
javafx.scene.control back to summary

private Class ScrollPane.StyleableProperties

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private static final CssMetaData<ScrollPane, Boolean>
private static final CssMetaData<ScrollPane, Boolean>
private static final CssMetaData<ScrollPane, ScrollPane.ScrollBarPolicy>
private static final CssMetaData<ScrollPane, Boolean>
private static final List<CssMetaData<? extends Styleable, ?>>
private static final CssMetaData<ScrollPane, ScrollPane.ScrollBarPolicy>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FIT_TO_HEIGHTback to summary
private static final CssMetaData<ScrollPane, Boolean> FIT_TO_HEIGHT
FIT_TO_WIDTHback to summary
private static final CssMetaData<ScrollPane, Boolean> FIT_TO_WIDTH
HBAR_POLICYback to summary
private static final CssMetaData<ScrollPane, ScrollPane.ScrollBarPolicy> HBAR_POLICY
PANNABLEback to summary
private static final CssMetaData<ScrollPane, Boolean> PANNABLE
STYLEABLESback to summary
private static final List<CssMetaData<? extends Styleable, ?>> STYLEABLES
VBAR_POLICYback to summary
private static final CssMetaData<ScrollPane, ScrollPane.ScrollBarPolicy> VBAR_POLICY

Constructor Detail

StyleablePropertiesback to summary
private StyleableProperties()