RFR: 8335587: TextInputControl: Binding prompt text that contains linebreak causes exception

Andy Goryachev angorya at openjdk.org
Tue Feb 4 15:52:15 UTC 2025


On Tue, 4 Feb 2025 14:11:00 GMT, Ziad El Midaoui <duke at openjdk.org> wrote:

> When binding the promptTextProperty of a TextInputControl (TextField or TextArea) to a text that contains linebreaks/newlines ("\n") the "bind" call causes a RuntimeException to be thrown, the solution to it is to unbind before calling the set(txt) method to set the new value for the property.
> Also added tests to test this new fix

modules/javafx.controls/src/main/java/javafx/scene/control/TextInputControl.java line 323:

> 321:             if (txt != null && txt.contains("\n")) {
> 322:                 txt = txt.replace("\n", "");
> 323:                 if(isBound()){

minor: try to match the existing formatting:
`if (isBound()) {`

(space after `if` and before `{`)

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

PR Review Comment: https://git.openjdk.org/jfx/pull/1694#discussion_r1941433595


More information about the openjfx-dev mailing list