RFR: 8351047: TitledPane should handle titles that are resizable

Andy Goryachev angorya at openjdk.org
Wed Mar 26 19:23:13 UTC 2025


On Tue, 25 Mar 2025 17:59:41 GMT, Andy Goryachev <angorya at openjdk.org> wrote:

>> This PR will forward more Label calculations to LabeledSkinBase, as they are quite complex, especially when a Graphic is involved which is a full-fledged `Node`. More specifically, this solves issues with TitledPane when the graphic is resizable (ie. an HBox is placed as Graphic in the titled pane's title area).  Before, the calculations would only look at the preferred size of the graphic, and use these regardless of available space, even if the maximum size allowed for the graphic to be larger. After this fix, the more extensive LabeledSkinBase calculations are used.
>> 
>> This PR also simplifies the layout calculation.  Instead of manually calculating where the label should be positioned (according to alignment), this is left to `layoutLabelInArea` which will do this automatically when its provided with the available space for the label instead of the label's width.
>> 
>> See the ticket for a sample program; take a look at the graphic-only case where an HBox is used to put a label + gap + button as the graphic of the titled pane.
>
> modules/javafx.controls/src/main/java/javafx/scene/control/skin/TitledPaneSkin.java line 514:
> 
>> 512:              */
>> 513: 
>> 514:             double labelPrefWidth = TitledPaneSkin.super.computePrefWidth(height, 0, 0, 0, 0);
> 
> On a related subject: trying to get the title label truncated (using the code sample in the ticket) did not succeed even though the TitledPane is a Labeled:
> 
> 
>         TitledPane tp1 = new TitledPane("Left Aligned Title with a long long title with ellipses set", ...);
>         tp1.setPrefWidth(100);
>         tp1.setMaxWidth(100);
>         tp1.setEllipsisString("...");
> 
> 
> This seems like a possible bug to me.  What do you think?

created https://bugs.openjdk.org/browse/JDK-8352991

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1742#discussion_r2014856478


More information about the openjfx-dev mailing list