0

I noticed that executing getScene() on nodes placed inside a TabPane returns null. Also getParent() returns null.

I need to call getScene() for a dialog which opens from a node in the hierarchy.

As an example my hierarchy is like this:

Stage-Scene-SplitPane-TabPane-Tab-TextArea

Inside textArea I open an Alert and call

myAlert.initOwner( textArea.getScene());

textArea.getScene() returns null, so the dialog shows on a different monitor (bad position and does not inherit css ). How may I avoid this?

SedJ601
  • 12,173
  • 3
  • 41
  • 59
DbSchema
  • 413
  • 5
  • 16
  • I'm unable to reproduce the issue. Please add a [mcve]. The issue could be the time when you retrieve the properties: If you access those properties before the `TabPane` skin is created, those values return `null` since the content has not yet been added as descendant of the `TabPane`. The skin should be created when the stage containing the `TabPane` is shown... – fabian Oct 16 '18 at 10:54
  • You are right. I have been creating a new tab, adding it to the tabPane and then showing the dialog in one single thread. I added Platform.runLater() when calling the dialog, and now everything works fine. – DbSchema Oct 17 '18 at 07:08

0 Answers0