On Tue, 20 May 2025 04:34:36 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> wrote:
>> The issue is when a JSplitPane is embedded inside a lazily-initialized >> panel, and this panel is displayed using a dialog created via >> JOptionPane.createDialog(), the divider location is not preserved when >> reopening the dialog. >> This is because when we added support for ComponentOrientation for >> JSplitPane, even though the left and right compoent is drawn the divider >> location is not set and was set to initial value and not to the value set by >> user. >> Fixed by setting the divider location before rendering the left and right >> components.. > > Prasanta Sadhukhan has updated the pull request incrementally with one > additional commit since the last revision: > > Click position fixed..L&F iteration setDividerLocation call is needed as when `BasicSplitPaneUI$BasicHorizontalLayoutManager.layoutContainer` is called to layout, it checks [`doReset ` and `dividerLocationIsSet` ](https://github.com/openjdk/jdk/blob/91194517c75a96fe7bcc2dcf5e9c42af9cf5975a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java#L1423-L1437) Now, when `JSplitPane.setComponentOrientation `calls `setLeftComponent `it sets `doReset `to true (in `BasicSplitPaneUI.addLayoutComponent`) so `resetToPreferredSizes` is called when we open the dialog the 2nd time. so it causes this issue Now if we call setDividerLocation it will set [dividerLocationIsSet](https://github.com/openjdk/jdk/blob/91194517c75a96fe7bcc2dcf5e9c42af9cf5975a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java#L1029) so even if `doReset `is true, it will not call `resetToPreferredSizes` but sets correct [divider location](https://github.com/openjdk/jdk/blob/91194517c75a96fe7bcc2dcf5e9c42af9cf5975a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicSplitPaneUI.java#L1436) ------------- PR Comment: https://git.openjdk.org/jdk/pull/25294#issuecomment-2897083731