RFR: 6741930: JOptionPane doesn't honour Focus Traversal Policy

Prasanta Sadhukhan psadhukhan at openjdk.org
Mon Feb 16 10:52:29 UTC 2026


The FocusTraversalPolicy of a JOptionPane (JDialog) "reports" via `FocusTraversalPolicy.getInitialComponent`/`FocusTraversalPolicy.getFirstComponnent` that the focusable component passed to a JOptionPane, should get the initial focus. This however doesn't always happen, as the text field's FocusListener methods focusGained and focusLost are not invoked.
Fix is made to honor the first focusable component of custom component (if present) and set the focus accordingly..
This will cause the component's focusGained/focusLost method to get called.
CI testing is ok..

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

Commit messages:
 - jcheck
 - 6741930: JOptionPane doesn't honour Focus Traversal Policy

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

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


More information about the client-libs-dev mailing list