Class StageDragBehaviour

java.lang.Object
com.dlsc.gemsfx.util.StageDragBehaviour

public class StageDragBehaviour extends Object
Allows dragging a node's containing Stage with the primary mouse button. The stage is resolved when a drag starts, so the behaviour can be installed before the node is attached to a scene or window. Nodes in non-stage windows are ignored. Event filters are used without consuming events or replacing existing handlers.
StageDragBehaviour dragging = StageDragBehaviour.install(titleBar);
dragging.enabledProperty().bind(draggingAllowed);
// When no longer needed:
dragging.uninstall();

Install, configure, and uninstall the behaviour on the JavaFX application thread.

  • Property Summary

    Properties
    Type
    Property
    Description
    final javafx.beans.property.BooleanProperty
    Determines whether mouse dragging moves the containing stage.
  • Method Summary

    Modifier and Type
    Method
    Description
    final javafx.beans.property.BooleanProperty
    Determines whether mouse dragging moves the containing stage.
    install(javafx.scene.Node node)
    Installs stage dragging on the given node, enabled by default.
    final boolean
    Gets the value of the enabled property.
    boolean
    Checks whether this behaviour is still installed.
    static boolean
    isInstalled(javafx.scene.Node node)
    Checks whether stage dragging is installed on the given node.
    final void
    setEnabled(boolean enabled)
    Sets the value of the enabled property.
    void
    Removes this behaviour's event filters and cancels any active drag.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Property Details

    • enabled

      public final javafx.beans.property.BooleanProperty enabledProperty
      Determines whether mouse dragging moves the containing stage. The default value is true. Disabling cancels any active drag.
      See Also:
  • Method Details

    • install

      public static StageDragBehaviour install(javafx.scene.Node node)
      Installs stage dragging on the given node, enabled by default.
      Parameters:
      node - the node to use as a drag handle
      Returns:
      the installed behaviour
      Throws:
      NullPointerException - if the node is null
      IllegalStateException - if stage dragging is already installed on the node
    • enabledProperty

      public final javafx.beans.property.BooleanProperty enabledProperty()
      Determines whether mouse dragging moves the containing stage. The default value is true. Disabling cancels any active drag.
      Returns:
      the enabled property
      See Also:
    • isEnabled

      public final boolean isEnabled()
      Gets the value of the enabled property.
      Property description:
      Determines whether mouse dragging moves the containing stage. The default value is true. Disabling cancels any active drag.
      Returns:
      the value of the enabled property
      See Also:
    • setEnabled

      public final void setEnabled(boolean enabled)
      Sets the value of the enabled property.
      Property description:
      Determines whether mouse dragging moves the containing stage. The default value is true. Disabling cancels any active drag.
      Parameters:
      enabled - the value for the enabled property
      See Also:
    • isInstalled

      public static boolean isInstalled(javafx.scene.Node node)
      Checks whether stage dragging is installed on the given node.
      Parameters:
      node - the node to check
      Returns:
      true if stage dragging is installed
    • isInstalled

      public boolean isInstalled()
      Checks whether this behaviour is still installed.
      Returns:
      true if this behaviour is installed
    • uninstall

      public void uninstall()
      Removes this behaviour's event filters and cancels any active drag. Calling this method more than once has no effect.