RFR: 4265389: JSplitPane does not support ComponentOrientation [v6]

Abhishek Kumar abhiscxk at openjdk.org
Mon Jul 22 07:08:39 UTC 2024


On Fri, 19 Jul 2024 08:05:06 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

>> JSplitPane's support of CompoentOrientation is not present so if orientation is RTL, it still renders left component on left and right component on right instead of other way around..
>> Fix to make it support RTL orientation
>
> 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.`

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

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


More information about the client-libs-dev mailing list