JavaFX Utils

DoubleClickable

Component that sets code to be triggered on double click of Node.

This component sets an EventHandler through button.setOnMouseClicked(handler) which checks click count and runs code in case of 2 clicks.

Constructors

public DoubleClickable(T node, Consumer <MouseEvent> action, boolean keepOldHandler)

  • node : Node in which DoubleClickable will be mounted.
  • action : action to be triggered on double click, this action receives the MouseEvent originated.
  • keepOldHandler : indicates if the EventHandler from node.getOnMouseClicked() is to keep or to be discarded.

There are more constructors with different parameters, but all will internally call this first one.

Variations :

  • Constructors that don't receive boolean keepOldHandler this value is assumed as true.
  • Constructors that receive Runnable action instead of Consumer<MouseEvent> action.
  • Constructors that receive IComponent<T> component obtain Node object from component.getNode().
public DoubleClickable(T node, Consumer<MouseEvent> action)
public DoubleClickable(T node, Runnable action, boolean keepOldHandler)
public DoubleClickable(T node, Runnable action)
public DoubleClickable(IComponent<T> component, Consumer<MouseEvent> action, boolean keepOldHandler)
public DoubleClickable(IComponent<T> component, Consumer<MouseEvent> action)
public DoubleClickable(IComponent<T> component, Runnable action, boolean keepOldHandler)
public DoubleClickable(IComponent<T> component, Runnable action)

Usage

	Node node;

	new DoubleClickable<>(node, this::onDoubleClick).mount();
					

Links