public class ScrollPane extends Control
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.), they need to wrap the scroll node in a Group.
ScrollPane sets focusTraversable to false.
This example creates a ScrollPane, which contains a Rectangle :
import javafx.scene.control.ScrollPane;
import javafx.scene.shape.Rectangle;
Rectangle rect = new Rectangle(200, 200, Color.RED);
ScrollPane s1 = new ScrollPane();
s1.setPrefSize(120, 120);
s1.setContent(rect);
Type | Property and Description |
---|---|
<any> |
content
The node used as the content of this ScrollPane.
|
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.
|
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.
|
<any> |
hbarPolicy
Specifies the policy for showing the horizontal scroll bar.
|
DoubleProperty |
hmax
The maximum allowable
hvalue for this ScrollPane. |
DoubleProperty |
hmin
The minimum allowable
hvalue for this ScrollPane. |
DoubleProperty |
hvalue
The current horizontal scroll position of the ScrollPane.
|
DoubleProperty |
minViewportHeight
Specify the minimum height of the ScrollPane Viewport.
|
DoubleProperty |
minViewportWidth
Specify the minimum width of the ScrollPane Viewport.
|
BooleanProperty |
pannable
Specifies whether the user should be able to pan the viewport by using
the mouse.
|
DoubleProperty |
prefViewportHeight
Specify the preferred height of the ScrollPane Viewport.
|
DoubleProperty |
prefViewportWidth
Specify the preferred width of the ScrollPane Viewport.
|
<any> |
vbarPolicy
Specifies the policy for showing the vertical scroll bar.
|
<any> |
viewportBounds
The actual Bounds of the ScrollPane Viewport.
|
DoubleProperty |
vmax
The maximum allowable
vvalue for this ScrollPane. |
DoubleProperty |
vmin
The minimum allowable
vvalue for this ScrollPane. |
DoubleProperty |
vvalue
The current vertical scroll position of the ScrollPane.
|
contextMenuProperty, skinClassNameProperty, skinProperty, tooltipProperty
Modifier and Type | Class and Description |
---|---|
static class |
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 |
ScrollPane.StyleableProperties |
Modifier and Type | Field and Description |
---|---|
private <any> |
content
The node used as the content of this ScrollPane.
|
private static java.lang.String |
DEFAULT_STYLE_CLASS
Initialize the style class to 'scroll-view'.
|
private static PseudoClass |
FIT_TO_HEIGHT_PSEUDOCLASS_STATE |
private static PseudoClass |
FIT_TO_WIDTH_PSEUDOCLASS_STATE |
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 <any> |
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 PseudoClass |
PANNABLE_PSEUDOCLASS_STATE |
private DoubleProperty |
prefViewportHeight
Specify the preferred height of the ScrollPane Viewport.
|
private DoubleProperty |
prefViewportWidth
Specify the preferred width of the ScrollPane Viewport.
|
private <any> |
vbarPolicy
Specifies the policy for showing the vertical scroll bar.
|
private <any> |
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 and Description |
---|
ScrollPane()
Creates a new ScrollPane.
|
ScrollPane(Node content)
Creates a new ScrollPane.
|
Modifier and Type | Method and Description |
---|---|
<any> |
contentProperty()
The node used as the content of this ScrollPane.
|
protected Skin<?> |
createDefaultSkin()
Create a new instance of the default skin for this control.
|
BooleanProperty |
fitToHeightProperty()
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.
|
BooleanProperty |
fitToWidthProperty()
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.
|
static java.util.List<<any>> |
getClassCssMetaData() |
Node |
getContent()
Gets the value of the property content.
|
java.util.List<<any>> |
getControlCssMetaData() |
ScrollPane.ScrollBarPolicy |
getHbarPolicy()
Gets the value of the property hbarPolicy.
|
double |
getHmax()
Gets the value of the property hmax.
|
double |
getHmin()
Gets the value of the property hmin.
|
double |
getHvalue()
Gets the value of the property hvalue.
|
protected java.lang.Boolean |
getInitialFocusTraversable()
Returns the initial focus traversable state of this control, for use
by the JavaFX CSS engine to correctly set its initial value.
|
double |
getMinViewportHeight()
Gets the value of the property minViewportHeight.
|
double |
getMinViewportWidth()
Gets the value of the property minViewportWidth.
|
double |
getPrefViewportHeight()
Gets the value of the property prefViewportHeight.
|
double |
getPrefViewportWidth()
Gets the value of the property prefViewportWidth.
|
ScrollPane.ScrollBarPolicy |
getVbarPolicy()
Gets the value of the property vbarPolicy.
|
Bounds |
getViewportBounds()
Gets the value of the property viewportBounds.
|
double |
getVmax()
Gets the value of the property vmax.
|
double |
getVmin()
Gets the value of the property vmin.
|
double |
getVvalue()
Gets the value of the property vvalue.
|
<any> |
hbarPolicyProperty()
Specifies the policy for showing the horizontal scroll bar.
|
DoubleProperty |
hmaxProperty()
The maximum allowable
hvalue for this ScrollPane. |
DoubleProperty |
hminProperty()
The minimum allowable
hvalue for this ScrollPane. |
DoubleProperty |
hvalueProperty()
The current horizontal scroll position of the ScrollPane.
|
boolean |
isFitToHeight()
Gets the value of the property fitToHeight.
|
boolean |
isFitToWidth()
Gets the value of the property fitToWidth.
|
boolean |
isPannable()
Gets the value of the property pannable.
|
DoubleProperty |
minViewportHeightProperty()
Specify the minimum height of the ScrollPane Viewport.
|
DoubleProperty |
minViewportWidthProperty()
Specify the minimum width of the ScrollPane Viewport.
|
BooleanProperty |
pannableProperty()
Specifies whether the user should be able to pan the viewport by using
the mouse.
|
DoubleProperty |
prefViewportHeightProperty()
Specify the preferred height of the ScrollPane Viewport.
|
DoubleProperty |
prefViewportWidthProperty()
Specify the preferred width of the ScrollPane Viewport.
|
java.lang.Object |
queryAccessibleAttribute(AccessibleAttribute attribute,
java.lang.Object... parameters) |
void |
setContent(Node value)
Sets the value of the property content.
|
void |
setFitToHeight(boolean value)
Sets the value of the property fitToHeight.
|
void |
setFitToWidth(boolean value)
Sets the value of the property fitToWidth.
|
void |
setHbarPolicy(ScrollPane.ScrollBarPolicy value)
Sets the value of the property hbarPolicy.
|
void |
setHmax(double value)
Sets the value of the property hmax.
|
void |
setHmin(double value)
Sets the value of the property hmin.
|
void |
setHvalue(double value)
Sets the value of the property hvalue.
|
void |
setMinViewportHeight(double value)
Sets the value of the property minViewportHeight.
|
void |
setMinViewportWidth(double value)
Sets the value of the property minViewportWidth.
|
void |
setPannable(boolean value)
Sets the value of the property pannable.
|
void |
setPrefViewportHeight(double value)
Sets the value of the property prefViewportHeight.
|
void |
setPrefViewportWidth(double value)
Sets the value of the property prefViewportWidth.
|
void |
setVbarPolicy(ScrollPane.ScrollBarPolicy value)
Sets the value of the property vbarPolicy.
|
void |
setViewportBounds(Bounds value)
Sets the value of the property viewportBounds.
|
void |
setVmax(double value)
Sets the value of the property vmax.
|
void |
setVmin(double value)
Sets the value of the property vmin.
|
void |
setVvalue(double value)
Sets the value of the property vvalue.
|
<any> |
vbarPolicyProperty()
Specifies the policy for showing the vertical scroll bar.
|
<any> |
viewportBoundsProperty()
The actual Bounds of the ScrollPane Viewport.
|
DoubleProperty |
vmaxProperty()
The maximum allowable
vvalue for this ScrollPane. |
DoubleProperty |
vminProperty()
The minimum allowable
vvalue for this ScrollPane. |
DoubleProperty |
vvalueProperty()
The current vertical scroll position of the ScrollPane.
|
computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, computePrefHeight, computePrefWidth, contextMenuProperty, executeAccessibleAction, getBaselineOffset, getContextMenu, getControlChildren, getCssMetaData, getSkin, getTooltip, isResizable, layoutChildren, loadSkinClass, setContextMenu, setSkin, setTooltip, skinClassNameProperty, skinProperty, tooltipProperty
public final <any> hbarPolicyProperty
getHbarPolicy()
,
setHbarPolicy(ScrollBarPolicy)
public final <any> vbarPolicyProperty
getVbarPolicy()
,
setVbarPolicy(ScrollBarPolicy)
public final <any> contentProperty
getContent()
,
setContent(Node)
public final DoubleProperty hvalueProperty
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
.getHvalue()
,
setHvalue(double)
public final DoubleProperty vvalueProperty
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
.getVvalue()
,
setVvalue(double)
public final DoubleProperty hminProperty
hvalue
for this ScrollPane.
Default value is 0.getHmin()
,
setHmin(double)
public final DoubleProperty vminProperty
vvalue
for this ScrollPane.
Default value is 0.getVmin()
,
setVmin(double)
public final DoubleProperty hmaxProperty
hvalue
for this ScrollPane.
Default value is 1.getHmax()
,
setHmax(double)
public final DoubleProperty vmaxProperty
vvalue
for this ScrollPane.
Default value is 1.getVmax()
,
setVmax(double)
public final BooleanProperty fitToWidthProperty
isFitToWidth()
,
setFitToWidth(boolean)
public final BooleanProperty fitToHeightProperty
isFitToHeight()
,
setFitToHeight(boolean)
public final BooleanProperty pannableProperty
pannable
is consulted to determine if the events should be
used for panning.isPannable()
,
setPannable(boolean)
public final DoubleProperty prefViewportWidthProperty
public final DoubleProperty prefViewportHeightProperty
public final DoubleProperty minViewportWidthProperty
getMinViewportWidth()
,
setMinViewportWidth(double)
public final DoubleProperty minViewportHeightProperty
getMinViewportHeight()
,
setMinViewportHeight(double)
public final <any> viewportBoundsProperty
getViewportBounds()
,
setViewportBounds(Bounds)
private <any> hbarPolicy
private <any> vbarPolicy
private <any> content
private DoubleProperty hvalue
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
.private DoubleProperty vvalue
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
.private DoubleProperty hmin
hvalue
for this ScrollPane.
Default value is 0.private DoubleProperty vmin
vvalue
for this ScrollPane.
Default value is 0.private DoubleProperty hmax
hvalue
for this ScrollPane.
Default value is 1.private DoubleProperty vmax
vvalue
for this ScrollPane.
Default value is 1.private BooleanProperty fitToWidth
private BooleanProperty fitToHeight
private BooleanProperty pannable
pannable
is consulted to determine if the events should be
used for panning.private DoubleProperty prefViewportWidth
private DoubleProperty prefViewportHeight
private DoubleProperty minViewportWidth
prefViewportWidthProperty()
private DoubleProperty minViewportHeight
prefViewportHeightProperty()
private <any> viewportBounds
private static final java.lang.String DEFAULT_STYLE_CLASS
private static final PseudoClass PANNABLE_PSEUDOCLASS_STATE
private static final PseudoClass FIT_TO_WIDTH_PSEUDOCLASS_STATE
private static final PseudoClass FIT_TO_HEIGHT_PSEUDOCLASS_STATE
public ScrollPane()
public ScrollPane(Node content)
content
- the initial content for the ScrollPanepublic final void setHbarPolicy(ScrollPane.ScrollBarPolicy value)
public final ScrollPane.ScrollBarPolicy getHbarPolicy()
public final <any> hbarPolicyProperty()
getHbarPolicy()
,
setHbarPolicy(ScrollBarPolicy)
public final void setVbarPolicy(ScrollPane.ScrollBarPolicy value)
public final ScrollPane.ScrollBarPolicy getVbarPolicy()
public final <any> vbarPolicyProperty()
getVbarPolicy()
,
setVbarPolicy(ScrollBarPolicy)
public final void setContent(Node value)
public final Node getContent()
public final <any> contentProperty()
getContent()
,
setContent(Node)
public final void setHvalue(double value)
public final double getHvalue()
public final DoubleProperty hvalueProperty()
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
.getHvalue()
,
setHvalue(double)
public final void setVvalue(double value)
public final double getVvalue()
public final DoubleProperty vvalueProperty()
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
.getVvalue()
,
setVvalue(double)
public final void setHmin(double value)
public final double getHmin()
public final DoubleProperty hminProperty()
hvalue
for this ScrollPane.
Default value is 0.getHmin()
,
setHmin(double)
public final void setVmin(double value)
public final double getVmin()
public final DoubleProperty vminProperty()
vvalue
for this ScrollPane.
Default value is 0.getVmin()
,
setVmin(double)
public final void setHmax(double value)
public final double getHmax()
public final DoubleProperty hmaxProperty()
hvalue
for this ScrollPane.
Default value is 1.getHmax()
,
setHmax(double)
public final void setVmax(double value)
public final double getVmax()
public final DoubleProperty vmaxProperty()
vvalue
for this ScrollPane.
Default value is 1.getVmax()
,
setVmax(double)
public final void setFitToWidth(boolean value)
public final boolean isFitToWidth()
public final BooleanProperty fitToWidthProperty()
isFitToWidth()
,
setFitToWidth(boolean)
public final void setFitToHeight(boolean value)
public final boolean isFitToHeight()
public final BooleanProperty fitToHeightProperty()
isFitToHeight()
,
setFitToHeight(boolean)
public final void setPannable(boolean value)
public final boolean isPannable()
public final BooleanProperty pannableProperty()
pannable
is consulted to determine if the events should be
used for panning.isPannable()
,
setPannable(boolean)
public final void setPrefViewportWidth(double value)
public final double getPrefViewportWidth()
public final DoubleProperty prefViewportWidthProperty()
public final void setPrefViewportHeight(double value)
public final double getPrefViewportHeight()
public final DoubleProperty prefViewportHeightProperty()
public final void setMinViewportWidth(double value)
public final double getMinViewportWidth()
public final DoubleProperty minViewportWidthProperty()
getMinViewportWidth()
,
setMinViewportWidth(double)
public final void setMinViewportHeight(double value)
public final double getMinViewportHeight()
public final DoubleProperty minViewportHeightProperty()
getMinViewportHeight()
,
setMinViewportHeight(double)
public final void setViewportBounds(Bounds value)
public final Bounds getViewportBounds()
public final <any> viewportBoundsProperty()
getViewportBounds()
,
setViewportBounds(Bounds)
protected Skin<?> createDefaultSkin()
-fx-skin
or set explicitly in a sub-class with setSkin(...)
.createDefaultSkin
in class Control
public static java.util.List<<any>> getClassCssMetaData()
public java.util.List<<any>> getControlCssMetaData()
getControlCssMetaData
in class Control
protected java.lang.Boolean getInitialFocusTraversable()
getInitialFocusTraversable
in class Control
public java.lang.Object queryAccessibleAttribute(AccessibleAttribute attribute, java.lang.Object... parameters)
queryAccessibleAttribute
in class Control