Usecase for needsLayout property?
John Hendrikx
hjohn at xs4all.nl
Wed Jun 5 02:29:25 PDT 2013
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