Class ClickRepeater

java.lang.Object
pamViewFX.fxNodes.picker.ClickRepeater

public final class ClickRepeater extends Object
Usually a ButtonBase only fires once per mouse click, namely when the mouse is released. This class allows a ButtonBase to periodically fire while armed, e.g. while the mouse is pressed.

While the button is armed, it waits 500ms to fire the first time. After that it fires every 80ms by default.

Therefore it mimics the behavior of key press events as they fire constantly, too, while the key is pressed.

Sample Usage

 
 Button button = new Button("I'll fire constantly");
 button.setOnAction(new EventHandler<ActionEvent>()} {
      @Override
      public void handle(ActionEvent actionEvent) {
         System.out.println("Fired!");
      }
 });
 ClickRepeater.install(button);
 
 
Author:
Christian Schudt
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    install(javafx.scene.control.ButtonBase buttonBase)
    Installs the click repeating behavior for a ButtonBase.
    static void
    install(javafx.scene.control.ButtonBase buttonBase, javafx.util.Duration interval)
    Installs the click repeating behavior for a ButtonBase and also allows to set a click interval.
    static void
    uninstall(javafx.scene.control.ButtonBase buttonBase)
    Uninstalls the click repeater behavior from a button.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • install

      public static void install(javafx.scene.control.ButtonBase buttonBase)
      Installs the click repeating behavior for a ButtonBase. The default click interval is 80ms.
      Parameters:
      buttonBase - The button.
    • install

      public static void install(javafx.scene.control.ButtonBase buttonBase, javafx.util.Duration interval)
      Installs the click repeating behavior for a ButtonBase and also allows to set a click interval.
      Parameters:
      buttonBase - The button.
      interval - The click interval.
    • uninstall

      public static void uninstall(javafx.scene.control.ButtonBase buttonBase)
      Uninstalls the click repeater behavior from a button.
      Parameters:
      buttonBase - The button.