RFR: 4265389: JSplitPane does not support ComponentOrientation [v6]
Prasanta Sadhukhan
psadhukhan at openjdk.org
Mon Jul 22 07:11:33 UTC 2024
On Mon, 22 Jul 2024 07:05:56 GMT, Abhishek Kumar <abhiscxk at openjdk.org> wrote:
>> Prasanta Sadhukhan has updated the pull request incrementally with one additional commit since the last revision:
>>
>> whitespace removal
>
> src/java.desktop/share/classes/javax/swing/JSplitPane.java line 375:
>
>> 373: Component leftComponent = this.getLeftComponent();
>> 374: Component rightComponent = this.getRightComponent();
>> 375: if (this.getComponentOrientation().equals(ComponentOrientation.RIGHT_TO_LEFT)) {
>
> Is it a good idea to use `isLeftToRight()` method to determine the component orientation?
> As per [ComponentOrientation spec](https://docs.oracle.com/en%2Fjava%2Fjavase%2F22%2Fdocs%2Fapi%2F%2F/java.desktop/java/awt/ComponentOrientation.html)
>
> >Components whose view and controller code depends on orientation should use the isLeftToRight() and isHorizontal() methods to determine their behavior. They should not include switch-like code that keys off of the constants, such as:
> if (orientation == LEFT_TO_RIGHT) {
> ...
> } else if (orientation == RIGHT_TO_LEFT) {
> ...
> } else {
> // Oops
> }
> This is unsafe, since more constants may be added in the future and since it is not guaranteed that orientation objects will be unique.`
good observation..will modify...
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20214#discussion_r1686068671
More information about the client-libs-dev
mailing list