-
Bug
-
Resolution: Fixed
-
P4
-
8, 9
-
b16
-
generic
-
generic
FULL PRODUCT VERSION :
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows 7, 64 bit
A DESCRIPTION OF THE PROBLEM :
I'm tring to use pseudo classes in programmtic query using Node.lookupAll() however this seems to give unexpected results.
I've searched online and can't find anything to suggest Node.lookupAll() wouldn't support psuedo classes...
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See test case
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
lookupAll() should return nodes according to selectors containing psuedo selectors
ACTUAL -
lookupAll() appears to ignore pseudo selectors and returns all nodes
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.css.PseudoClass;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Foo extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
PseudoClass pseudoClass = PseudoClass.getPseudoClass("custom");
Label a = new Label();
a.getStyleClass().add("foo");
a.pseudoClassStateChanged(pseudoClass, false);
Label b = new Label();
b.getStyleClass().add("foo");
a.pseudoClassStateChanged(pseudoClass, true);
Label c = new Label();
c.getStyleClass().add("foo");
a.pseudoClassStateChanged(pseudoClass, true);
HBox box = new HBox(a, b, c);
primaryStage.setScene(new Scene(box));
System.out.println(box.lookupAll(":custom").size()); // expected 2
System.out.println(box.lookupAll(".foo:custom").size()); // expected 2
System.out.println(box.lookupAll(".foo").size()); // expected 3, got 3
System.out.println(box.lookupAll(":magichorse").size()); // expected 0 !!
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't use pseudo selectors in lookupAll(). Instead use getPseudoClassStates()
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Windows 7, 64 bit
A DESCRIPTION OF THE PROBLEM :
I'm tring to use pseudo classes in programmtic query using Node.lookupAll() however this seems to give unexpected results.
I've searched online and can't find anything to suggest Node.lookupAll() wouldn't support psuedo classes...
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See test case
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
lookupAll() should return nodes according to selectors containing psuedo selectors
ACTUAL -
lookupAll() appears to ignore pseudo selectors and returns all nodes
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javafx.application.Application;
import javafx.css.PseudoClass;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.stage.Stage;
public class Foo extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
PseudoClass pseudoClass = PseudoClass.getPseudoClass("custom");
Label a = new Label();
a.getStyleClass().add("foo");
a.pseudoClassStateChanged(pseudoClass, false);
Label b = new Label();
b.getStyleClass().add("foo");
a.pseudoClassStateChanged(pseudoClass, true);
Label c = new Label();
c.getStyleClass().add("foo");
a.pseudoClassStateChanged(pseudoClass, true);
HBox box = new HBox(a, b, c);
primaryStage.setScene(new Scene(box));
System.out.println(box.lookupAll(":custom").size()); // expected 2
System.out.println(box.lookupAll(".foo:custom").size()); // expected 2
System.out.println(box.lookupAll(".foo").size()); // expected 3, got 3
System.out.println(box.lookupAll(":magichorse").size()); // expected 0 !!
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Don't use pseudo selectors in lookupAll(). Instead use getPseudoClassStates()