Class AccessibilityUtil

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

public final class AccessibilityUtil extends Object
Small helper methods used by the GemsFX controls to add a baseline of accessibility metadata (screen-reader support).

The GemsFX convention is:

  • every user-facing control sets an AccessibleRole in its constructor, and
  • value-bearing controls derive their accessibleText from their own state.
The accessibleText helpers deliberately yield to application code: once an application explicitly calls Node.setAccessibleText(String) with a value that this class did not write, the automatic updates stop so the application value always wins.
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    bindAccessibleText(javafx.scene.Node node, javafx.beans.value.ObservableValue<String> source)
    Keeps the accessibleText of the given node in sync with the value of the given observable, without overriding a value that the application has set itself.
    static void
    setRole(javafx.scene.Node node, javafx.scene.AccessibleRole role)
    Sets the accessible role on the given node.
    static void
    setRole(javafx.scene.Node node, javafx.scene.AccessibleRole role, String roleDescription)
    Sets the accessible role and role description on the given node.

    Methods inherited from class Object

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

    • setRole

      public static void setRole(javafx.scene.Node node, javafx.scene.AccessibleRole role)
      Sets the accessible role on the given node.
      Parameters:
      node - the node, may be null (ignored)
      role - the accessible role
    • setRole

      public static void setRole(javafx.scene.Node node, javafx.scene.AccessibleRole role, String roleDescription)
      Sets the accessible role and role description on the given node. The role description is a short, localized, human-readable name for the type of control (for example "avatar").
      Parameters:
      node - the node, may be null (ignored)
      role - the accessible role
      roleDescription - a human-readable description of the role
    • bindAccessibleText

      public static void bindAccessibleText(javafx.scene.Node node, javafx.beans.value.ObservableValue<String> source)
      Keeps the accessibleText of the given node in sync with the value of the given observable, without overriding a value that the application has set itself.

      The node's accessible text is updated whenever the source changes, but only as long as the current accessible text is still the value this method last wrote (or is empty). As soon as application code sets a different accessible text, the automatic updates stop.

      Parameters:
      node - the node whose accessible text should be maintained, may be null
      source - the observable providing the accessible text