Class FocusUtil

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

public class FocusUtil extends Object
Utility class providing focus-related helper methods for JavaFX nodes.

This class contains static methods for requesting and delegating keyboard focus in a safe way, ensuring that focus requests are deferred until the target node is actually showing in the scene graph.

  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    delegateFocus(javafx.scene.Node receiver, javafx.scene.Node delegate)
    Delegates the focus from one node to another.
    static javafx.scene.Node
    findFirstFocusableNode(javafx.scene.Node node)
    Finds the first FocusTraversable node in the tree hierarchy of a given node.
    static void
    focusOnFirstFocusableNode(javafx.scene.Node node)
    Requests focus on the first focusable node below the given node.
    static void
    requestFocus(javafx.scene.Node node)
    Requests focus on the specified node if the node is visible in the tree hierarchy.

    Methods inherited from class Object

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

    • requestFocus

      public static void requestFocus(javafx.scene.Node node)
      Requests focus on the specified node if the node is visible in the tree hierarchy. The node will receive the keyboard focus if it is currently showing.
      Parameters:
      node - The node to request focus on.
    • delegateFocus

      public static void delegateFocus(javafx.scene.Node receiver, javafx.scene.Node delegate)
      Delegates the focus from one node to another.
      Parameters:
      receiver - the node receiving the initial focus
      delegate - the node that should receive the delegated focus
    • findFirstFocusableNode

      public static javafx.scene.Node findFirstFocusableNode(javafx.scene.Node node)
      Finds the first FocusTraversable node in the tree hierarchy of a given node.
      Parameters:
      node - The node to start the search from.
      Returns:
      The first focusable node found, or null if no focusable node is found.
    • focusOnFirstFocusableNode

      public static void focusOnFirstFocusableNode(javafx.scene.Node node)
      Requests focus on the first focusable node below the given node.
      Parameters:
      node - the node used to start the search