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 Summary
| Modifier | Constructor | Description |
|---|---|---|
protected |
Constructor for subclasses to call. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
abstract boolean |
applies |
Gets whether this Selector applies to the given Styleable. |
abstract boolean |
applies |
Gets whether this Selector applies to the given Styleable. |
final Match |
createMatch() |
Creates a Match. |
static Selector |
createSelector |
Creates a Selector object. |
int |
getOrdinal() |
Gets the ordinal of this Selector. |
Rule |
getRule() |
Gets the Rule of this Selector. |
abstract Set |
getStyleClassNames() |
Gets the immutable set of style class names of this Selector. |
void |
setOrdinal |
Sets the ordinal of this Selector. |
abstract boolean |
stateMatches |
Determines whether the current state of the Node and its parents matches the pseudo-classes defined (if any) for this selector. |
Constructor Details
Selector
protected Selector()
Constructor for subclasses to call.
- Since:
- 24
Method Details
getRule
public Rule getRule()
Gets the
Rule of this Selector.- Returns:
- rule
setOrdinal
public void setOrdinal(int ordinal)
Sets the ordinal of this Selector.
- Parameters:
-
ordinal- the ordinal of this Selector
getOrdinal
public int getOrdinal()
Gets the ordinal of this Selector.
- Returns:
- the ordinal of this Selector
getStyleClassNames
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 containsnulls, but can be empty - Since:
- 23
createMatch
public final Match createMatch()
Creates a
Match.- Returns:
- a match, never
null
applies
public abstract boolean applies(Styleable styleable)
Gets whether this
Selector applies to the given Styleable.- Parameters:
-
styleable- theStyleableto match - Returns:
-
trueif thisSelectorapplies to the givenStyleable
applies
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- theStyleableto match -
triggerStates- a set ofPseudoClassstates -
depth- depth of theNodehierarchy to look for - Returns:
-
trueif thisSelectorand a set ofPseudoClassapplies to the givenStyleable
stateMatches
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:
-
trueif the current state of the node and its parents matches the pseudo-classes defined (if any) for this selector
createSelector
public static Selector createSelector(String cssSelector)
Creates a
Selector object.- Parameters:
-
cssSelector- CSS selector string - Returns:
- a
Selector
© 2008, 2025, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from JavaFX API Documentation.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Java, JavaFX and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.