<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hi,<br>
</p>
<p>In this case, this is because SplitPane doesn't actually add its
split items as children -- only its Skin does this. Skins are
AFAIK installed after a CSS pass.</p>
<p>In the split pane case, I guess a Skin could choose to completely
leave out a child if its splitter completely hides it (ie, dragged
all the way to the left or right if allowed).</p>
<p>This may be another case where it may make sense to have both a
document graph (logical graph) and a scene graph as Michael
Strauss mentioned here:
<a class="moz-txt-link-freetext" href="https://mail.openjdk.org/pipermail/openjfx-dev/2022-June/034417.html">https://mail.openjdk.org/pipermail/openjfx-dev/2022-June/034417.html</a></p>
<p>I doubt this is documented anywhere at all, it's one of those
things that doesn't work quite right in JavaFX before a Scene is
displayed.<br>
</p>
<p>--John<br>
</p>
<div class="moz-cite-prefix">On 23/12/2022 23:49, Scott Palmer
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:2C7CB4BB-5FC3-4185-9CA3-1202F804E407@gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
I just want to make sure this is not expected behaviour. I don’t
think so, the documentation for lookupAll doesn’t mention anything
related, but maybe I missed something somewhere else.
<div><br>
<div>I was just coding something to query the Scene for all
SplitPanes and save/restore the divider positions for when my
application is exiting and launching and came across this
issue.</div>
<div>My UI is fully constructed (at least in terms of all the
SplitPanes in the scene graph) before it is shown.</div>
<div><br>
</div>
<div>This code:</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space:pre"> </span><font
face="Courier New">window.getScene().getRoot().lookupAll(".split-pane")</font><br>
<div><br>
</div>
</div>
<div>returns a different number of Nodes if I call it before
showing the window versus after showing the window.
Specifically, if I call it before showing the window it
appears to only return the first SplitPane found in the scene
graph, but calling it in an event handler for the window shown
event I get all three.</div>
<div><br>
</div>
<div>This can be demonstrated with the following program:</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div><font face="Courier New">import
javafx.application.Application;</font></div>
<div><font face="Courier New">import javafx.scene.Scene;</font></div>
<div><font face="Courier New">import
javafx.scene.control.SplitPane;</font></div>
<div><font face="Courier New">import
javafx.scene.control.TextArea;</font></div>
<div><font face="Courier New">import
javafx.scene.layout.BorderPane;</font></div>
<div><font face="Courier New">import javafx.stage.Stage;</font></div>
<div><font face="Courier New">import javafx.stage.Window;</font></div>
<div><font face="Courier New"><br>
</font></div>
<div><font face="Courier New">public class LookupAll extends
Application {</font></div>
<div><font face="Courier New"> Window mainWindow;</font></div>
<div><font face="Courier New"> </font></div>
<div><font face="Courier New"> public static void
main(String[] args) {</font></div>
<div><font face="Courier New"> launch(args);</font></div>
<div><font face="Courier New"> }</font></div>
<div><font face="Courier New"> </font></div>
<div><font face="Courier New"> @Override</font></div>
<div><font face="Courier New"> public void start(Stage
primaryStage) throws Exception {</font></div>
<div><font face="Courier New"> var bp = new
BorderPane(new SplitPane(new TextArea(),new SplitPane(new
TextArea(),new SplitPane(new TextArea()))));</font></div>
<div><font face="Courier New"> var scene = new Scene(bp);</font></div>
<div><font face="Courier New">
primaryStage.setScene(scene);</font></div>
<div><font face="Courier New"> mainWindow = primaryStage;</font></div>
<div><font face="Courier New"> System.out.println("Before
showing:");</font></div>
<div><font face="Courier New"> countSplitPanes();</font></div>
<div><font face="Courier New"> primaryStage.setOnShown(we
-> {</font></div>
<div><font face="Courier New">
System.out.println("After showing:");</font></div>
<div><font face="Courier New"> countSplitPanes();</font></div>
<div><font face="Courier New"> });</font></div>
<div><font face="Courier New"> primaryStage.show();</font></div>
<div><font face="Courier New"> }</font></div>
<div><font face="Courier New"> </font></div>
<div><font face="Courier New"> private void countSplitPanes()
{</font></div>
<div><font face="Courier New"> var splitPanes =
mainWindow.getScene().getRoot().lookupAll(".split-pane");</font></div>
<div><font face="Courier New"> System.out.printf("Found
%d SpitPanes: %s\n",splitPanes.size(), splitPanes);</font></div>
<div><font face="Courier New"> }</font></div>
<div><font face="Courier New">}</font></div>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div>Before showing:</div>
<div>Found 1 SpitPanes:
[SplitPane@16bca2d9[styleClass=split-pane]]</div>
<div>After showing:</div>
<div>Found 3 SpitPanes:
[SplitPane@16bca2d9[styleClass=split-pane],
SplitPane@7078ef3c[styleClass=split-pane],
SplitPane@56a29626[styleClass=split-pane]]</div>
</div>
<div><br>
</div>
<div><br>
</div>
<div>Regards,</div>
<div><br>
</div>
<div>Scott</div>
<div><br>
</div>
</blockquote>
</body>
</html>