Class Selector

java.lang.Object
javafx.css.Selector

public abstract sealed class Selector extends Object
Used by CSSRule to determine whether or not the Selector applies to a given object.
Since:
9
  • Constructor Details Link icon

    • Selector Link icon

      protected Selector()
      Constructor for subclasses to call.
      Since:
      24
  • Method Details Link icon

    • getRule Link icon

      public Rule getRule()
      Gets the Rule of this Selector.
      Returns:
      rule
    • setOrdinal Link icon

      public void setOrdinal(int ordinal)
      Sets the ordinal of this Selector.
      Parameters:
      ordinal - the ordinal of this Selector
    • getOrdinal Link icon

      public int getOrdinal()
      Gets the ordinal of this Selector.
      Returns:
      the ordinal of this Selector
    • getStyleClassNames Link icon

      public abstract Set<String> getStyleClassNames()
      Gets the immutable set of style class names of this Selector.
      Returns:
      an immutable set with style class names, never null, or contains nulls, but can be empty
      Since:
      23
    • createMatch Link icon

      public final Match createMatch()
      Creates a Match.
      Returns:
      a match, never null
    • applies Link icon

      public abstract boolean applies(Styleable styleable)
      Gets whether this Selector applies to the given Styleable.
      Parameters:
      styleable - the Styleable to match
      Returns:
      true if this Selector applies to the given Styleable
    • applies Link icon

      public abstract boolean applies(Styleable styleable, Set<PseudoClass>[] triggerStates, int depth)
      Gets whether this Selector applies to the given Styleable. It is the same as the applies(javafx.css.Styleable) method except it also returns PseudoClass state that it finds along the way.
      Parameters:
      styleable - the Styleable to match
      triggerStates - a set of PseudoClass states
      depth - depth of the Node hierarchy to look for
      Returns:
      true if this Selector and a set of PseudoClass applies to the given Styleable
    • stateMatches Link icon

      public abstract boolean stateMatches(Styleable styleable, Set<PseudoClass> state)
      Determines whether the current state of the Node and its parents matches the pseudo-classes defined (if any) for this selector.
      Parameters:
      styleable - the styleable
      state - the state
      Returns:
      true if the current state of the node and its parents matches the pseudo-classes defined (if any) for this selector
    • createSelector Link icon

      public static Selector createSelector(String cssSelector)
      Creates a Selector object.
      Parameters:
      cssSelector - CSS selector string
      Returns:
      a Selector