mentics
mentics

Reputation: 6999

JavaFX delay execution until added to scene

Sometimes there are actions one wants to take on a Node but one needs access to the Scene or for other reasons needs it to be added to the Scene first.

In Swing, I could use a hierarchy change listener to do this. Is there some type of notification or event when a Node is added to the hierarchy so that getScene will return non-null?

Upvotes: 0

Views: 142

Answers (1)

jewelsea
jewelsea

Reputation: 159416

Add a ChangeListener to the node's sceneProperty to be notified to changes of the scene the node is attached to, including when the scene property changes from null to some value.

Upvotes: 2

Related Questions