I have an instance of a Group sub-class to which I am adding other Groups.
One of the Groups is a Group's sub-class that has a method getCollision().
In that method I am running a for each cycle to inspect all children of that group's parent:
public Node getCollision() {
System.out.printf("Entering get collision %s\n", From.getId());
for (Node n: this.getParent().getChildren()) {
System.out.printf("n class: %s id %s\n", n.getClass(), n.getId());
Problem is, the output never mentions the Groups's subclass where getCollision is executing and several other Groups added to the parent. Among the objects that are mentioned is a PointLight of the scene for example, as it is a child of this.getParent(), but several others including getCollision() owner Group are missing. AmbientLight is missing too.
(Also tried a regular for loop for (int i = 0; i < this.getParent().getChildren().size(); i++) with the exact same results).
For now I am kind of Okay with the other objects missing in the getChildren() result, but how on Earth it is possible that getCollision is called, but it's class's object is not in the parent's getChildren() after being added???
This is how I added them to the parent:
final PointLight sunLight = new PointLight(Color.WHITE);
sunLight.setId("point_light");
this.Scape.getChildren().add(sunLight);
final AmbientLight ambLight = new AmbientLight(Color.rgb(50, 50, 50));
ambLight.setId("ambient_light");
this.Scape.getChildren().add(ambLight);
final MyChar person1 = new MyChar();
person1.setId("person1");
this.Scape.getChildren().add(person1);
final MyChar person2 = new MyChar();
person2.setId("person2");
this.Scape.getChildren().add(person2);
...
final BouncingBall bb = new BouncingBall();
bb.setId("bouncing_ball");
this.Scape.getChildren().add(bb);
person2.getBall().Kick(bb, person2.getTranslateX(), person2.getTranslateY(), person2.getTranslateZ()); // Method Kick calls getCollision() in a Timeline
So when a person2 kicks his ball, timeline starts playing and it's checking for collisions. In getCollision() I only encounter some objects, including the lights created above, but not person1 and not person2.
None of my code has any kind of filtering that could apply to getChildren() that I know of. None of the API calls are overridden and there are no threads other than UI.
This is OS dependent apparently. The original question arose under XP 64bit SP2, which JavaFX 8 officially does not want to support. Same test performed under Win7 32bit SP1 returned all children of the group.
Edit: Actually it is now looking more like a 32bit vs 64bit issue, as the issue exists under Win7 64bit, but not under Win7 32bit.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With