JDK-8324491 : Keyboard layout didn't keep its state if it was changed when dialog was active
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 8,11,17,21,22
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: windows
  • CPU: x86_64
  • Submitted: 2024-01-10
  • Updated: 2024-12-06
  • Resolved: 2024-12-03
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 24
24 b27Fixed
Related Reports
Relates :  
Description
A DESCRIPTION OF THE PROBLEM :
Similar problem with JDK-8187635, but different scenario. In this case, keyboard layout is changed when a dialog is active. After the dialog is closed, the keyboard layout will revert to previous layout.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- Run sample code.
- Click one of the button, a dialog will appear.
- Change keyboard layout (i.e from English to Russia).
- Close the dialog, and keyboard layout will revert to English.

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Keyboard layout keep its state.
ACTUAL -
Keyboard layout revert to previous before it was changed.

---------- BEGIN SOURCE ----------
public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> {
            JFrame jFrame = new JFrame("Test");

            JDialog dialog = new JDialog(jFrame, "dialog", true);
            dialog.setSize(new Dimension(100,100));
            JButton button1 = new JButton();
            button1.setText("dialog");
            button1.addActionListener(e -> dialog.setVisible(true));

            JButton button2 = new JButton();
            button2.setText("option");
            button2.addActionListener(e -> JOptionPane.showMessageDialog(jFrame, "optionPane"));

            JPanel panel = new JPanel();
            panel.add(button1);
            panel.add(button2);

            jFrame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
            jFrame.add(panel);
            jFrame.setSize(new Dimension(300, 100));
            jFrame.setVisible(true);
        });
    }
---------- END SOURCE ----------

FREQUENCY : always



Comments
Changeset: 2be07b5f Branch: master Author: Dmitry Markov <dmarkov@openjdk.org> Date: 2024-12-03 18:37:27 +0000 URL: https://git.openjdk.org/jdk/commit/2be07b5f9d2f3f0b885feb08ff10a57824ea5748
03-12-2024

A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/22411 Date: 2024-11-27 12:47:29 +0000
27-11-2024

Problem description: If AWT/Swing app displays several windows and an user changes the keyboard layout and then closes the focused window, the app does not keep the keyboard layout changes. Fix: It is necessary to sync currentLocale and Windows keyboard layout values in WInputMethod class before component activation.
27-11-2024

Relates to JDK-8187635 different scenario
23-01-2024

Checked with attached testcase in Windows11, Issue is reproducible<attached short clipping> Step to reproduce ------------------------------ $java AppTest Click on dialog button >>dialog will appear. (keyboard Layout : English (US)) Change keyboard layout (keyboard Layout : German) Close the dialog ( Keyboard layout will revert to English keyboard Layout : English (US)) Click on dialog button (keyboard Layout : German) Test Result ========== jdk8: Fail 8u401: Fail jdk11: Fail jdk17: Fail jdk21: Fail jdk22ea31: Fail
23-01-2024