Class Selector
java.lang.Object
javafx.css.Selector
- Direct Known Subclasses:
-
CompoundSelector,SimpleSelector
public abstract class Selector
extends Object Used by
CSSRule to determine whether or not the Selector applies to a given object.- Since:
- 9
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
abstract boolean | applies(Styleable styleable) | Gets whether this Selector applies to the given Styleable. |
abstract boolean | applies(Styleable styleable,
Set<PseudoClass>[] triggerStates,
int depth) | Gets whether this Selector applies to the given Styleable. |
abstract Match | createMatch() | Creates a Match. |
static Selector | createSelector(String cssSelector) | Creates a Selector object. |
int | getOrdinal() | Gets the ordinal of this Selector. |
Rule | getRule() | Gets the Rule of this Selector. |
void | setOrdinal(int ordinal) | Sets the ordinal of this Selector. |
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. |
protected void | writeBinary(DataOutputStream os,
StyleConverter.StringStore stringStore) | Writes Selector data in binary form to given DataOutputStream. |
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
createMatch
public abstract Match createMatch()
Creates a
Match.- Returns:
- match
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 theNodeheirarchy 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
writeBinary
protected void writeBinary(DataOutputStream os, StyleConverter.StringStore stringStore) throws IOException
Writes
Selector data in binary form to given DataOutputStream.- Parameters:
-
os-DataOutputStreamto writeSelectordata to -
stringStore- unused - Throws:
-
IOException- if writing toDataOutputStreamfails
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.