Usecase for needsLayout property?

Martin Sladecek martin.sladecek at
Wed Jun 5 04:04:16 PDT 2013

Hi John,
the problem you described is most likely caused by something else as the 
layout pass occurs BEFORE the actual rendering.
Also, you bind managed and visible of the entire VBox, not just the 
title. So it's strange that you see Label correctly laid-out, but not 
the content.

Can you make some sample and attach it to a JIRA issue, so I can have a 
look what's actually happening there?


On 06/05/2013 11:29 AM, John Hendrikx wrote:
> I'm having a bit of a chicken-egg problem with regards to some 
> dynamically sized components I'm displaying in my application.
> Description:
> I have a group with a title that wraps some content and displays a 
> title above it -- the entire group, including the title must be hidden 
> and unmanaged when the content it is wrapping is empty, here it is in 
> code:
> protected Pane createTitledBlock(final String title, final Node 
> content, final BooleanExpression visibleCondition) {
> return new VBox() {{
> setFillWidth(true);
> getChildren().add(new Label(title) {{
> getStyleClass().add("header");
> }});
> getChildren().add(content);
> if(visibleCondition != null) {
> managedProperty().bind(visibleCondition);
> visibleProperty().bind(visibleCondition);
> }
> }};
> }
> Problem:
> When the content becomes available and visibleCondition gets toggled 
> to true, the content part of the titled group is not yet laid out. 
> This causes the title to be visible without any content briefly until 
> a layout pass occurs.
> Timeline:
> - Group with title is hidden/unmanaged
> - The content gets updated and visibleCondition is set to true
> - Group with title becomes visible/managed
> - Briefly an empty group with title is displayed
> - Layout occurs, group with title gets resized
> Now, I'm thinking of playing with the needsLayout property and 
> delaying the making visible/managed of the titled group until 
> needsLayout is false... however, I have a feeling that won't work as 
> an unmanaged/hidden group is probably not gonna participate in the 
> layout, resulting in needsLayout never becoming false again as it is 
> not visible/managed yet...
> Any ideas how I could resolve this, and have the group with title only 
> visible and managed when it is properly laid out?
> Also, has any progress in general been made with regards to 
> hidden/unmanaged controls and determining their expected size when 
> they're made visible/managed?
> --John

More information about the openjfx-dev mailing list