Is there is the way to find parent Node ( high in hierarchy ) via method? Element id or class can be use.
Any alternative to something like this?
source.getParent().getParent().getParent().getParent().getParent().getParent();
ObservableList<Node> getChildren() Gets the list of children of this Parent .
Every Scene needs exactly one Parent as the root .
A node may occur at most once anywhere in the scene graph. Specifically, a node must appear no more than once in all of the following: as the root node of a Scene , the children ObservableList of a Parent , or as the clip of a Node . The scene graph must not have cycles.
Class Parent. The base class for all nodes that have children in the scene graph. This class handles all hierarchical scene graph operations, including adding/removing child nodes, marking branches dirty for layout and rendering, picking, bounds calculations, and executing the layout pass on each pulse.
You can lookup any Node by its ID from the Scene object.
For example:
Scene scene = source.getScene();
Node nodeToFind = scene.lookup("#nodeToFindId");
The ID is a CSS selector (id), or an FX ID. It has to be set up on the node without the '#' character. When invoking the method 'lookup', the '#' character has to precede the ID, like above.
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