PrefWidth/Height calculations only works if stage is shown

Richard Bair richard.bair at oracle.com
Thu Aug 8 14:29:29 PDT 2013


Yes, the problem is that CSS has not been executed yet. If you call reapplyCSS (did we add that API yet? or is it still that impl_?) then you can get a proper size from the control.

Richard

On Aug 8, 2013, at 2:26 PM, Tom Schindl <tom.schindl at bestsolution.at> wrote:

> Hi,
> 
> I've been trying to open a window in the minimal dimension needed by
> components but it looks like size calculations prefHeight/prefWidth only
> works if the stage is shown.
> 
> I need the dimensions before showing the stage because I want to
> position it on the lower right of the screen before showing the stage
> because if doing it afterwards leads to flickering.
> 
> 
>> BorderPane g = new BorderPane();
>> TableView<String> v = new TableView<String>();
>> g.setCenter(v);
>> Scene s = new Scene(g);
>> primaryStage.setScene(s);
>> System.err.println(g.prefWidth(-1)); // 0
>> primaryStage.show();
>> System.err.println(g.prefWidth(-1)); // 248
> 
> Is this working as designed?
> 
> Tom



More information about the openjfx-dev mailing list