Top Description Fields Constructors Methods
com.dlsc.gemsfx

public Class DrawerStackPane

extends StackPane
Class Inheritance
Imports
javafx.animation.*, javafx.beans.InvalidationListener, javafx.beans.binding.Bindings, javafx.beans.property.*, javafx.collections.FXCollections, .ObservableList, javafx.geometry.Pos, javafx.scene.CacheHint, .Cursor, .Node, javafx.scene.control.Button, .Label, .Separator, .ToolBar, javafx.scene.input.KeyCode, .KeyEvent, .MouseButton, javafx.scene.layout.HBox, .Priority, .Region, .StackPane, .VBox, javafx.util.Duration, java.util.Objects, java.util.logging.Level, .Logger, java.util.prefs.Preferences

A custom stackpane that supports a drawer view sliding in from bottom to top. The content of the drawer gets added in the normal way via the childrens list. The content for the drawer has to be added by calling setDrawerContent(Node).

Features

Field Summary

Modifier and TypeField and Description
private final BooleanProperty
private final ObjectProperty<Duration>
private final BooleanProperty
private VBox
private final ObjectProperty<Node>
private final DoubleProperty
private final StringProperty
private final ObjectProperty<Node>
private final BooleanProperty
private GlassPane
private HBox
private static final Logger
private final DoubleProperty
private final DoubleProperty
private final ObjectProperty<Runnable>
private final ObjectProperty<Runnable>
private final StringProperty
private final DoubleProperty
private final BooleanProperty
private final BooleanProperty
private final DoubleProperty
private double
private Timeline
private final ListProperty<Node>
private final DoubleProperty

Constructor Summary

AccessConstructor and Description
public
DrawerStackPane(Node...
the children nodes
nodes
)

Constructs a new drawer stack pane.

public
DrawerStackPane()

Constructs a new drawer stack pane.

Method Summary

Modifier and TypeMethod and Description
private void
addExtra(HBox headerBox, Node oldExtra, Node newExtra)

public final BooleanProperty

Returns:

true if the drawer will be animated (slide in / out)
animateDrawerProperty
()

Determines whether the drawer will smoothly slide in / out when the user opens / closes it.

public final ObjectProperty<Duration>

Returns:

the animation duration
animationDurationProperty
()

The duration it takes to show / hide the drawer.

public BooleanProperty

Returns:

true if the drawer hides when user clicks on background
autoHideProperty
()

Makes the drawer close if the user clicks in the background (onto the glass pane).

private VBox
private StackPane
private String
private Label
private ToolBar
public final ObjectProperty<Node>

Returns:

the drawer content
drawerContentProperty
()

Stores the content of the drawer.

public final DoubleProperty

Returns:

the drawer height (value between 0 and 1)
drawerHeightProperty
()

Stores the current height of the drawer as a value between 0 (not showing) and 1 (using full height of stackpane).

public final ObjectProperty<Node>

Returns:

an extra node that will be added to the title bar
drawerTitleExtraProperty
()

An extra node that will be added to the title bar.

public final StringProperty

Returns:

the drawer title text
drawerTitleProperty
()

The text shown as the title of the drawer.

public final BooleanProperty

Returns:

true if the glass pane will fade in / out smoothly when appearing / disappearing
fadeInOutProperty
()

Specifies whether the glass pane (used for blocking user input to nodes in the background) will use a fade transition when it becomes visible.

public final Duration
public final Node
public final double
public final String
public final Node
public double
public double
public Runnable
public final Runnable
public final String

Returns:

the preferences key
getPreferencesKey
()

Returns the key that will be used when storing the last drawer height via the Java preferences API.

public final double
public final double
public final ObservableList<Node>
public final double
public String
getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method.

private void
private void
init()

public final boolean
public boolean
public final boolean
public 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 double
public DoubleProperty

Returns:

the maximum drawer height (value between 0 and 1)
maxDrawerHeightProperty
()

The maximum drawer height, a value between 0 and 1 with 1 meaning that the drawer can be as high as the stackpane.

public DoubleProperty

Returns:

the minimum drawer height (value between 0 and 1)
minDrawerHeightProperty
()

The minimum drawer height, a value between 0 and 1 with 0 meaning that the drawer can be made completely invisible.

public ObjectProperty<Runnable>

Returns:

the callback for closing the drawer
onCloseRequestProperty
()

A callback that will be called when the user clicks on the close button or onto the glass pane.

public final ObjectProperty<Runnable>

Returns:

a callback that will be invoked when the drawer gets closed
onDrawerCloseProperty
()

A callback that will be invoked when the drawer gets closed.

private void
public final StringProperty

Returns:

the preferences key property
preferencesKeyProperty
()

Stores the key used to store the drawer height via the preferences store.

public final DoubleProperty

Returns:

the preferred drawer width
preferredDrawerWidthProperty
()

Stores the preferred width of the drawer.

private void
public final void
setAnimateDrawer(boolean animateDrawer)

public final void
setAnimationDuration(Duration animationDuration)

public void
setAutoHide(boolean autoHide)

public final void
setDrawerContent(Node drawerContent)

public final void
setDrawerHeight(double drawerHeight)

public void
setDrawerTitle(String drawerTitle)

public final void
setDrawerTitleExtra(Node drawerTitleExtra)

public final void
setFadeInOut(boolean fadeInOut)

public void
setMaxDrawerHeight(double maxDrawerHeight)

public void
setMinDrawerHeight(double minDrawerHeight)

public void
setOnCloseRequest(Runnable onCloseRequest)

public final void
setOnDrawerClose(Runnable onDrawerClose)

public final void
setPreferencesKey(String
the preferences key
key
)

Sets the key that will be used when storing the last drawer height via the Java preferences API.

public final void
setPreferredDrawerWidth(double preferredDrawerWidth)

public final void
setShowDrawer(boolean showDrawer)

public final void
setShowDrawerTitle(boolean showDrawerTitle)

public final void
setSidePadding(double sidePadding)

public final void
public final void
setTopPadding(double topPadding)

private void
public final BooleanProperty

Returns:

true if the drawer should show itself
showDrawerProperty
()

A flag used to control whether the drawer should show itself or not.

public final BooleanProperty

Returns:

true if the drawer shows a title
showDrawerTitleProperty
()

A flag used to signal whether the drawer should have a title bar or not.

public final DoubleProperty

Returns:

the padding used for the left and right side next to the drawer
sidePaddingProperty
()

Specifies a value used for padding to the left and the right of the drawer.

private void
public final ListProperty<Node>

Returns:

the toolbar items / toolbar buttons
toolbarItemsProperty
()

The list of items to display in the toolbar.

public final DoubleProperty

Returns:

the padding used for the top of the drawer
topPaddingProperty
()

Specifies a value used for padding at the top of the drawer.

Inherited from javafx.scene.layout.StackPane:
alignmentPropertyclearConstraintscomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthgetAlignmentgetAlignmentgetClassCssMetaDatagetContentBiasgetCssMetaDatagetMarginrequestLayoutsetAlignmentsetAlignmentsetMargin

Field Detail

animateDrawerback to summary
private final BooleanProperty animateDrawer
animationDurationback to summary
private final ObjectProperty<Duration> animationDuration
autoHideback to summary
private final BooleanProperty autoHide
drawerback to summary
private VBox drawer
drawerContentback to summary
private final ObjectProperty<Node> drawerContent
drawerHeightback to summary
private final DoubleProperty drawerHeight
drawerTitleback to summary
private final StringProperty drawerTitle
drawerTitleExtraback to summary
private final ObjectProperty<Node> drawerTitleExtra
fadeInOutback to summary
private final BooleanProperty fadeInOut
glassPaneback to summary
private GlassPane glassPane
headerBoxback to summary
private HBox headerBox
LOGback to summary
private static final Logger LOG
maxDrawerHeightback to summary
private final DoubleProperty maxDrawerHeight
minDrawerHeightback to summary
private final DoubleProperty minDrawerHeight
onCloseRequestback to summary
private final ObjectProperty<Runnable> onCloseRequest
onDrawerCloseback to summary
private final ObjectProperty<Runnable> onDrawerClose
preferencesKeyback to summary
private final StringProperty preferencesKey
preferredDrawerWidthback to summary
private final DoubleProperty preferredDrawerWidth
showDrawerback to summary
private final BooleanProperty showDrawer
showDrawerTitleback to summary
private final BooleanProperty showDrawerTitle
sidePaddingback to summary
private final DoubleProperty sidePadding
startYback to summary
private double startY
timelineback to summary
private Timeline timeline
toolbarItemsback to summary
private final ListProperty<Node> toolbarItems
topPaddingback to summary
private final DoubleProperty topPadding

Constructor Detail

DrawerStackPaneback to summary
public DrawerStackPane(Node... nodes)

Constructs a new drawer stack pane.

Parameters
nodes:Node[]

the children nodes

DrawerStackPaneback to summary
public DrawerStackPane()

Constructs a new drawer stack pane.

Method Detail

addExtraback to summary
private void addExtra(HBox headerBox, Node oldExtra, Node newExtra)
animateDrawerPropertyback to summary
public final BooleanProperty animateDrawerProperty()

Determines whether the drawer will smoothly slide in / out when the user opens / closes it. If not then the drawer will just appear instantly.

Returns:BooleanProperty

true if the drawer will be animated (slide in / out)

animationDurationPropertyback to summary
public final ObjectProperty<Duration> animationDurationProperty()

The duration it takes to show / hide the drawer.

Returns:ObjectProperty<Duration>

the animation duration

autoHidePropertyback to summary
public BooleanProperty autoHideProperty()

Makes the drawer close if the user clicks in the background (onto the glass pane).

Returns:BooleanProperty

true if the drawer hides when user clicks on background

createContainerback to summary
private VBox createContainer()
createDragHandleback to summary
private StackPane createDragHandle()
createPreferenceKeyback to summary
private String createPreferenceKey()
createTitleLabelback to summary
private Label createTitleLabel()
createToolBarback to summary
private ToolBar createToolBar()
drawerContentPropertyback to summary
public final ObjectProperty<Node> drawerContentProperty()

Stores the content of the drawer.

Returns:ObjectProperty<Node>

the drawer content

drawerHeightPropertyback to summary
public final DoubleProperty drawerHeightProperty()

Stores the current height of the drawer as a value between 0 (not showing) and 1 (using full height of stackpane).

Returns:DoubleProperty

the drawer height (value between 0 and 1)

drawerTitleExtraPropertyback to summary
public final ObjectProperty<Node> drawerTitleExtraProperty()

An extra node that will be added to the title bar.

Returns:ObjectProperty<Node>

an extra node that will be added to the title bar

drawerTitlePropertyback to summary
public final StringProperty drawerTitleProperty()

The text shown as the title of the drawer.

Returns:StringProperty

the drawer title text

fadeInOutPropertyback to summary
public final BooleanProperty fadeInOutProperty()

Specifies whether the glass pane (used for blocking user input to nodes in the background) will use a fade transition when it becomes visible.

Returns:BooleanProperty

true if the glass pane will fade in / out smoothly when appearing / disappearing

getAnimationDurationback to summary
public final Duration getAnimationDuration()
getDrawerContentback to summary
public final Node getDrawerContent()
getDrawerHeightback to summary
public final double getDrawerHeight()
getDrawerTitleback to summary
public final String getDrawerTitle()
getDrawerTitleExtraback to summary
public final Node getDrawerTitleExtra()
getMaxDrawerHeightback to summary
public double getMaxDrawerHeight()
getMinDrawerHeightback to summary
public double getMinDrawerHeight()
getOnCloseRequestback to summary
public Runnable getOnCloseRequest()
getOnDrawerCloseback to summary
public final Runnable getOnDrawerClose()
getPreferencesKeyback to summary
public final String getPreferencesKey()

Returns the key that will be used when storing the last drawer height via the Java preferences API.

Returns:String

the preferences key

getPreferredDrawerWidthback to summary
public final double getPreferredDrawerWidth()
getSidePaddingback to summary
public final double getSidePadding()
getToolbarItemsback to summary
public final ObservableList<Node> getToolbarItems()
getTopPaddingback to summary
public final double getTopPadding()
getUserAgentStylesheetback to summary
public String getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

Doc from javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. These styles are used in addition to whatever user-agent stylesheets are in use. This provides a mechanism for third parties to introduce styles for custom controls.

The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath.

Subclasses overriding this method should not assume any particular implementation approach as to the number and frequency with which it is called. For this reason, attempting any kind of dynamic implementation (i.e. returning different user agent stylesheet values) based on some state change is highly discouraged, as there is no guarantee when, or even if, this method will be called. Some JavaFX CSS implementations may choose to cache this response for an indefinite period of time, and therefore there should be no expectation around when this method is called.



package com.example.javafx.app;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class MyApp extends Application {

    @Override public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        scene.getStylesheets().add("/com/example/javafx/app/mystyles.css");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
For additional information about using CSS with the scene graph, see the CSS Reference Guide.
Annotations
@Override
hideDrawerback to summary
private void hideDrawer()
initback to summary
private void init()
isAnimateDrawerback to summary
public final boolean isAnimateDrawer()
isAutoHideback to summary
public boolean isAutoHide()
isFadeInOutback to summary
public final boolean isFadeInOut()
isShowDrawerback to summary
public boolean isShowDrawer()
isShowDrawerTitleback to summary
public final boolean isShowDrawerTitle()
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
loadDrawerHeightFromUserPreferencesback to summary
private double loadDrawerHeightFromUserPreferences()
maxDrawerHeightPropertyback to summary
public DoubleProperty maxDrawerHeightProperty()

The maximum drawer height, a value between 0 and 1 with 1 meaning that the drawer can be as high as the stackpane.

Returns:DoubleProperty

the maximum drawer height (value between 0 and 1)

minDrawerHeightPropertyback to summary
public DoubleProperty minDrawerHeightProperty()

The minimum drawer height, a value between 0 and 1 with 0 meaning that the drawer can be made completely invisible. Even with a value larger than 0 the drawer can be made to hide by the user by continuing to drag below the drawer.

Returns:DoubleProperty

the minimum drawer height (value between 0 and 1)

onCloseRequestPropertyback to summary
public ObjectProperty<Runnable> onCloseRequestProperty()

A callback that will be called when the user clicks on the close button or onto the glass pane. The default implementation of this callback will eventually call setShowDrawer(boolean).

Returns:ObjectProperty<Runnable>

the callback for closing the drawer

onDrawerClosePropertyback to summary
public final ObjectProperty<Runnable> onDrawerCloseProperty()

A callback that will be invoked when the drawer gets closed.

Returns:ObjectProperty<Runnable>

a callback that will be invoked when the drawer gets closed

postHidingback to summary
private void postHiding()
preferencesKeyPropertyback to summary
public final StringProperty preferencesKeyProperty()

Stores the key used to store the drawer height via the preferences store.

Returns:StringProperty

the preferences key property

preferredDrawerWidthPropertyback to summary
public final DoubleProperty preferredDrawerWidthProperty()

Stores the preferred width of the drawer. Normally this value is equal to -1, which indicates that the drawer should use the entire available width. A value larger than -1 will make the pane use that value for the width of the drawer. A value of Region#USE_PREF_SIZE will make the pane use the preferred width of the content shown inside the drawer.

Returns:DoubleProperty

the preferred drawer width

saveDrawerHeightToUserPreferencesback to summary
private void saveDrawerHeightToUserPreferences()
setAnimateDrawerback to summary
public final void setAnimateDrawer(boolean animateDrawer)
setAnimationDurationback to summary
public final void setAnimationDuration(Duration animationDuration)
setAutoHideback to summary
public void setAutoHide(boolean autoHide)
setDrawerContentback to summary
public final void setDrawerContent(Node drawerContent)
setDrawerHeightback to summary
public final void setDrawerHeight(double drawerHeight)
setDrawerTitleback to summary
public void setDrawerTitle(String drawerTitle)
setDrawerTitleExtraback to summary
public final void setDrawerTitleExtra(Node drawerTitleExtra)
setFadeInOutback to summary
public final void setFadeInOut(boolean fadeInOut)
setMaxDrawerHeightback to summary
public void setMaxDrawerHeight(double maxDrawerHeight)
setMinDrawerHeightback to summary
public void setMinDrawerHeight(double minDrawerHeight)
setOnCloseRequestback to summary
public void setOnCloseRequest(Runnable onCloseRequest)
setOnDrawerCloseback to summary
public final void setOnDrawerClose(Runnable onDrawerClose)
setPreferencesKeyback to summary
public final void setPreferencesKey(String key)

Sets the key that will be used when storing the last drawer height via the Java preferences API.

Parameters
key:String

the preferences key

setPreferredDrawerWidthback to summary
public final void setPreferredDrawerWidth(double preferredDrawerWidth)
setShowDrawerback to summary
public final void setShowDrawer(boolean showDrawer)
setShowDrawerTitleback to summary
public final void setShowDrawerTitle(boolean showDrawerTitle)
setSidePaddingback to summary
public final void setSidePadding(double sidePadding)
setToolbarItemsback to summary
public final void setToolbarItems(ObservableList<Node> items)
setTopPaddingback to summary
public final void setTopPadding(double topPadding)
showDrawerback to summary
private void showDrawer()
showDrawerPropertyback to summary
public final BooleanProperty showDrawerProperty()

A flag used to control whether the drawer should show itself or not.

Returns:BooleanProperty

true if the drawer should show itself

showDrawerTitlePropertyback to summary
public final BooleanProperty showDrawerTitleProperty()

A flag used to signal whether the drawer should have a title bar or not.

Returns:BooleanProperty

true if the drawer shows a title

sidePaddingPropertyback to summary
public final DoubleProperty sidePaddingProperty()

Specifies a value used for padding to the left and the right of the drawer. This value will always be enforced, not matter what the preferred width of the drawer content is.

Returns:DoubleProperty

the padding used for the left and right side next to the drawer

stopCurrentlyRunningTimelineback to summary
private void stopCurrentlyRunningTimeline()
toolbarItemsPropertyback to summary
public final ListProperty<Node> toolbarItemsProperty()

The list of items to display in the toolbar.

Returns:ListProperty<Node>

the toolbar items / toolbar buttons

topPaddingPropertyback to summary
public final DoubleProperty topPaddingProperty()

Specifies a value used for padding at the top of the drawer. This value will always be enforced,.

Returns:DoubleProperty

the padding used for the top of the drawer