<AWT Dev> Review Request for 8055197: TextField deletes multiline strings

Ambarish Rapte ambarish.rapte at oracle.com
Thu Oct 29 14:28:46 UTC 2015

Hi Sergey,

	The webrev is updated with using System.lineSeparator() instead of System.getProperty("line.separator").

	Webrev: http://cr.openjdk.java.net/~rchamyal/ambarish/8055197/webrev.01/

	Reason for using array:
		System.lineSeparator()  differs platform wise.
		Windows: \r\n
		Linux: \n
		Mac: \r

		But '\n' is a generic new line character, which programmers can add manually in string as,  "Row1 \n Row2"
		To handle this case, have added it in array.
		There is also a bug reported for this case,
		https://bugs.openjdk.java.net/browse/JDK-7186036 : TextField class does not show text after CR on Windows

		Similarly '\r' can also be considered,
		but '\r' is not commonly used &
		Also presence of '\r' in string does not result in truncation of text.

Many Thanks,

-----Original Message-----
From: Sergey Bylokhov 
Sent: Thursday, October 29, 2015 12:20 AM
To: Ambarish Rapte; awt-dev at openjdk.java.net; Alexander Scherbatiy
Subject: Re: Review Request for 8055197: TextField deletes multiline strings

Hi, Ambarish.
What is the reason to use this array? 
{System.getProperty("line.separator"), "\n"} Why we cannot use only the System.getProperty("line.separator") or which is simpler the System.lineSeparator();

On 14.10.15 19:44, Ambarish Rapte wrote:
> Dear All,
>      Please review the patch for jdk9.
>      Bug: https://bugs.openjdk.java.net/browse/JDK-8055197
>      Webrev: 
> http://cr.openjdk.java.net/~rchamyal/ambarish/8055197/webrev.00/
> Issue:
>      - If text containing new line character is set to TextField, Text after new line character was terminated.
>      - Issue occurs only on windows.
> Cause:
>      - For windows new line character is   ‘\r\n’.
>      - For windows code this new line character was not replaced by space character.
>      - Other platforms replace the EOL character by space character.
> Fix:
>      - Added code to TextComponent.java to remove EOL on java side before passing to peer.
>        => Added a private method replaceEOL() , which replaces EOL by space.
>        => removeEOL will be called by newly added TextComponent 
> construcotr and setText()
>      - The text variable on in TextComponent.java & on string displayed on native side will be same.
> Many Thanks,
> Ambarish

Best regards, Sergey.

More information about the awt-dev mailing list