Get Pane size without adding it to a scene (in JavaFX)?
<p>If I create a <code>Pane</code> (with nodes inside it), how can I compute the width/height without rendering it on-screen?</p>

<p>I am trying to create a document (in memory) and send it to a printer. The problem is that I need to compute how many pages and to <em><strong>do that</strong></em> I need to get the dimensions of the document.</p>

<p>A quick example I'm experimenting with:</p>

<pre><code>Label testLabel1 = new Label("TEST1");
Label testLabel2 = new Label("TEST no. 2");
GridPane testGl = new GridPane();
testGl.add( testLabel1, 1, 1 );
testGl.add( testLabel2, 2, 2 );
VBox testVBox = new VBox( testGl );
Pane testPane = new Pane( testVBox );

//I read that this might be required
testPane.applyCss();
testPane.layout();

//Also that a delay is needed for the fx tread to update testPane
// (but shouldn't this all be in the same thread since it is in the same function?
// It doesn't seem to help).
Platform.runLater(  ()-&gt;{
    System.out.println( "&gt;&gt;&gt; "+ testPane.getBoundsInLocal().getWidth() );
});
</code></pre>

<p>All I ever output is <code>&gt;&gt;&gt; 0.0</code>. Note that in the program I'm developing, I have multiple <code>Pane</code>s inside a "container" <code>Pane</code>. Hence, the variable <code>testPane</code>.</p>

<p>Thank you.</p>