• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

What are Nodes and Scene Nodes?

Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to learn just the mere basics of JavaFX and I saw the word node in several other places (like in LinkedLists). I still don't exactly understand what they are. The Node class is described like this:
"Base class for scene graph nodes. A scene graph is a set of tree data structures where every item has zero or one parent, and each item is either a "leaf" with zero sub-items or a "branch" with zero or more sub-items. "
I understand that a scene node is a set of tree data structures, but I can't visually picture this in my head.
Posts: 74712
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not certain myself, but let's imagine a tree. Let us say you have a scene and on that scene there are several other display nodes. Let's imagine you have a panel on the left and that has three buttons on. Now you have a single panel on the right with an image on. Now you can draw a diagram:-Now join those words up with arrows.

I shall move this discussion to our FX forum, where people will doubtless know the correct answer
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is no difference.  JavaFX just has a Node type, there is no specific SceneNode type.
I guess one way you could look at it are as unattached and attached nodes.
When you first create a node it is not attached to a scene.
For example:

Now you can place the node in a parent container:

The node is still not attached to a scene but it is in part of a node hierarchy (a scene graph), which is a structure that the JavaFX system is maintaining.
The node can be placed in a scene, by attaching it directly or by attaching a parent of it's hierarchy:

The scene can be made "active" by placing it on a Stage and showing the stage.

A key restriction that applies to nodes which are part of a scene graph attached to an active scene is that you cannot manipulate the active scene graph or properties of those nodes off of the JavaFX application thread.  Nodes which are not attached to an active scene can be modified on any thread (except a WebView node).
JavaFX runs a pulse system where it can process and refresh the active scene graph on a regular basis (usually 60 times a second), when a portion of a scene graph becomes dirty (requires updates) based upon a change to the scene graph, an animation, a CSS rule, a layout update, a user window resize or control interaction etc.  That pulse process is pretty much transparent to a JavaFX application programmer, but the fact that it is a managed process by the JavaFX system is what forces the requirement that active scene graph nodes can only be modified on the JavaFX application thread (the rule prevents race conditions in the processing of scene graph nodes).

Further information on the architecture and how it works can be found at:
I highly recommend reading the linked article as it will do a better job of explaining the principles than I just did above.

Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic