On Mon, 22 Jul 2024 09:00:05 GMT, Abhishek Kumar <[email protected]> wrote:

>>> There's a problem to it as ComponentOrientation can be LTR, RTL or UNKNOWN 
>>> (ie orientation not set) so just checking for isLeftToRIght will not work 
>>> as !LTR can be RTL or UNKNOWN so it will not work for the present scenario 
>>> so I guess we need to use the present way only..
>> 
>> You are right as !LTR can be one of RTL or UNKNOWN but it is mentioned in 
>> [ComponentOrientation](https://github.com/kumarabhi006/jdk/blob/70f3e99016311a6520e6a7c0da4c7ff718364976/src/java.desktop/share/classes/java/awt/ComponentOrientation.java#L120)
>>  class that `isLeftToRight will return true for UNKNOWN value`.
>> 
>>   /**
>>      * Indicates that a component's orientation has not been set.
>>      * To preserve the behavior of existing applications,
>>      * isLeftToRight will return true for this value.
>>      */
>>     public static final ComponentOrientation UNKNOWN =
>>                     new ComponentOrientation(HORIZ_BIT|LTR_BIT|UNK_BIT);
>> 
>> So, I guess this should be fine to check for `!isLeftToRIght()` to add 
>> components in a RTL else in LTR.
>> 
>> 
>>> if (!this.getComponentOrientation().isLeftToRight()) {
>>>      // handle RTL orientation
>>> } else {
>>>      // handle LTR / UNKNOWN orientation
>>> }
>
>> It does seem like it...all textfield/textarea even if orientation not set, 
>> it writes text in LTR, right?
> 
> Mentioned in 
> [Component](https://docs.oracle.com/en%2Fjava%2Fjavase%2F22%2Fdocs%2Fapi%2F%2F/java.desktop/java/awt/Component.html#setComponentOrientation(java.awt.ComponentOrientation))
>  class about UNKNOWN orientation
> 
> `At construction time, a component's orientation is set to 
> ComponentOrientation.UNKNOWN, indicating that it has not been specified 
> explicitly. The UNKNOWN orientation behaves the same as 
> ComponentOrientation.LEFT_TO_RIGHT. `

ok

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20214#discussion_r1686219235

Reply via email to