RFR: 8356594: JSplitPane loses divider location when reopened via JOptionPane.createDialog()

Sergey Bylokhov serb at openjdk.org
Tue May 20 00:11:51 UTC 2025


On Mon, 19 May 2025 06:06:17 GMT, Prasanta Sadhukhan <psadhukhan at 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..

test/jdk/javax/swing/JSplitPane/TestSplitPaneResetDividerLoc.java line 71:

> 69:                 point = openDialogButton.getLocationOnScreen();
> 70:             });
> 71:             robot.mouseMove(point.x, point.y);

When I run the test on my macOS laptop, it fails because the click occured on the window border instead of the button. It would be good to slightly shift the click position to ensure it reliably hits the button across platforms.

btw it is better to use EventQueue.invokeAndWait instead of SwingUtilities.invokeAndWait. The latter was added early on, while the former consolidates all event-dispatching utilities in one class.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25294#discussion_r2096631099


More information about the client-libs-dev mailing list