Class FXMLAnimationUtil

java.lang.Object
com.serinity.accesscontrol.util.FXMLAnimationUtil

public final class FXMLAnimationUtil extends Object
Utility class for handling animations in JavaFX FXML components.

This class provides static helper methods to perform common animations on JavaFX nodes, such as sliding a WebView in and out of the viewport. It is designed to simplify UI transitions and make code more readable and maintainable.

NOTE: All methods in this class are static, and the class cannot be instantiated.

Since:
2026-02-09 FXMLAnimationUtil.java
Version:
1.0
Author:
@ZouariOmar (zouariomar20@gmail.com)
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    slideFromTop(javafx.scene.Node node, double distance, int duration, boolean autoHide, int hideDelaySeconds)
    Animates a Node by sliding it vertically from top to bottom and optionally hides it after a delay.
    static void
    slideFullScreen(javafx.scene.web.WebView node, double stageWidth, boolean shift)
    Animates a WebView by sliding it horizontally across the screen.

    Methods inherited from class Object

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

    • slideFullScreen

      public static void slideFullScreen(javafx.scene.web.WebView node, double stageWidth, boolean shift)
      Animates a WebView by sliding it horizontally across the screen.

      If shift is true, the WebView will slide to the right edge of the stage. If shift is false, it will slide back to its original position (x = 0). This is useful for creating smooth UI transitions when showing or hiding full-screen content.

      Parameters:
      node - the WebView to animate
      stageWidth - the width of the stage, used to calculate the target X position
      shift - whether to slide the WebView out (true) or back to its original position (false)
      See Also:
      • // Example usage:
        WebView webView = new WebView();
        double stageWidth = 1024;
        // Slide the WebView out to full screen
        FXMLAnimationUtil.slideFullScreen(webView, stageWidth, true);
        // Slide the WebView back to its original position
        FXMLAnimationUtil.slideFullScreen(webView, stageWidth, false);
        
    • slideFromTop

      public static void slideFromTop(javafx.scene.Node node, double distance, int duration, boolean autoHide, int hideDelaySeconds)
      Animates a Node by sliding it vertically from top to bottom and optionally hides it after a delay.

      Useful for status messages, notifications, or temporary banners in your UI.

      Parameters:
      node - the Node to animate (e.g., Label)
      distance - how far to slide the node (positive = down)
      duration - duration of the slide animation in milliseconds
      autoHide - if true, the node will slide back and be hidden after hideDelaySeconds
      hideDelaySeconds - seconds to wait before hiding the node
      // Example usage:
      FXMLAnimationUtil.slideFromTop(messageStatusLabel, 50, 500, true, 3);