RFR: 4459231: Focus of JTabbedPane(with Scrollable tablayout) changes on change in LookAndFeel

Prasanta Sadhukhan psadhukhan at openjdk.org
Mon Dec 1 09:16:19 UTC 2025


On changing LookAndFeel of JTabbedPane, it resets the focus of the child tabs to starting child tab.
That is, if a JTabbedPane has say 10 tabs and we select the 10th tab and then we change the L&F, the focus is shifted to Tab0 even though the selected tab is still at 10th tab.

This is because when we switch L&F, `installUI ` will reset the `focusIndex ` 
https://github.com/openjdk/jdk/blob/3481252ced7c06c44154ceccc56b12cfd9a490c3/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTabbedPaneUI.java#L285-L290

which needs to set the proper focus by calling `scrollRectToVisible ` to selected tab which is done in this fix.

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

Commit messages:
 - jcheck
 - jcheck
 - 4459231: Focus of JTabbedPane(with Scrollable tablayout) changes on change in LookAndFeel

Changes: https://git.openjdk.org/jdk/pull/28571/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28571&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-4459231
  Stats: 119 lines in 2 files changed: 119 ins; 0 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/28571.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/28571/head:pull/28571

PR: https://git.openjdk.org/jdk/pull/28571


More information about the client-libs-dev mailing list