JDK-8324491 : Keyboard layout did not keep it state if it was changed when dialog is active
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 8,11,17,21,22
  • Priority: P3
  • Status: New
  • Resolution: Unresolved
  • OS: windows
  • CPU: x86_64
  • Submitted: 2024-01-10
  • Updated: 2024-01-23
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
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