RFR: 8335547: Support multi-line prompt text for TextArea
Michael Strauß
mstrauss at openjdk.org
Sun Mar 16 09:13:03 UTC 2025
On Thu, 13 Mar 2025 17:36:35 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> Added multi line prompt support for TextArea this will provide the ability to have multiple lines in textArea as expected,
>> Also fixed tests to meet the new changes
>
> modules/javafx.controls/src/main/java/javafx/scene/control/skin/TextFieldSkin.java line 739:
>
>> 737: s = s.replace("\n", "");
>> 738: return s;
>> 739: }, getSkinnable().promptTextProperty()));
>
> two minor problems:
> 1. missing { } after `if`. (I would highly recommend always using { })
> 2. when s is null you call replace() unnecessarily
>
> suggestion:
>
> String s = getSkinnable().getPromptText();
> if (s == null) {
> return "";
> }
> return s.replace("\n", "");
You should consider using a fluent binding here, which is a more modern solution compared to the `Bindings` class. It is also simpler because you don't need to check for `null`:
promptNode.textProperty().bind(getSkinnable().promptTextProperty().map(s -> s.replace("\n", "")));
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1716#discussion_r1997537410
More information about the openjfx-dev
mailing list