RFR: 8180276: JTextPane getText return extra when mixed with methods of Document [v5]

Alexey Ivanov aivanov at openjdk.java.net
Mon Apr 11 10:42:36 UTC 2022


On Mon, 11 Apr 2022 10:26:35 GMT, Tejesh R <duke at openjdk.java.net> wrote:

> > Is it a bug then?
> 
> It is not a bug I guess, it is as expected and as commented out about the logic in `read()` method...... The bug states this statement " But if we use append() first and then setText(pane.getText + newText), before every \r\n another \r is added, and in output, extra blank line are added."...... In windows extra \r was added because of the previous logic, it was causing an extra empty line......

There will be no extra line if `System.lineSeparator()` is not used. And it shouldn't be used with text APIs: the text model always uses Linux/macOS style line ends that is `\n` only.

If you add `\r` into the text model, eventually it'll get converted to `\n` as specified by `DefaultEditorKit`.

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

PR: https://git.openjdk.java.net/jdk/pull/8122



More information about the client-libs-dev mailing list