1
votes

I know did lots and lots of reading and they keep saying the same thing. A root node doesn't have any parent nodes but only have children nodes.

  1. If I only have stage and a scene but zero node, would I still have a root node by default?
  2. If I have two nodes, one is a circle and the other is a square, which one is a root node?
1

1 Answers

4
votes

If I only have stage and a scene but zero node

This is impossible. There is no constructor for a Scene that doesn't take a root node parameter (and if you pass null, you simply get a NullPointerException). So if you have a scene, you necessarily have a root node.

If I have two nodes, one is a circle and the other is a square, which one is a root node?

Neither, since neither is an instance of Parent, and the root property of Scene is a Parent.

The only way to display any node is to either have it as the root of a scene, or to have it as a child of the root, or the child of a child of the root, etc.

So if the Circle and square (presumably a Rectangle) are both displayed, they must both be descendants of some root node.