On Mon, 22 Jul 2024 07:20:35 GMT, Prasanta Sadhukhan <[email protected]> wrote:
>>> just checking for isLeftToRIght will not work as !LTR can be RTL or UNKNOWN >> >> Does that mean if orientation is UNKNOWN, it should be LTR by default ? > > It does seem like it...all textfield/textarea even if orientation not set, it > writes text in LTR, right? > 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 > } ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/20214#discussion_r1686196627
