Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8334114

[SwingNode, Linux] Cannot focus JTextField in SwingNode inside Tab

XMLWordPrintable

    • x86_64
    • linux_ubuntu

      ADDITIONAL SYSTEM INFORMATION :
      Ubuntu: 22.04
      Kernel: 5.15.0-107-generic #117-Ubuntu SMP Fri Apr 26 12:26:49 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
      Running on X11 KDE 5.24.7 with Nvidia GPU 535.171.04

      java version "22.0.1" 2024-04-16
      Java(TM) SE Runtime Environment (build 22.0.1+8-16)
      Java HotSpot(TM) 64-Bit Server VM (build 22.0.1+8-16, mixed mode, sharing)

      A DESCRIPTION OF THE PROBLEM :
      When running the provided example code, the JTextFields in the second tab (named "not works") cannot be focused or edited as expected. When switching back and forth between the tabs, the first tab also starts to behave the same.

      This issue happens always when running on Linux, however on Windows focus works as expected.

      Other swing components than JTextField could also be affected, although buttons do work and react on mouse click.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      - run example code on Linux
      - select secondary tab called "not works"
      - try to focus "Field 3" or "Field 4" with the mouse and edit it

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      - text field does focus and can be edited as one would expect from any text field
      ACTUAL -
      - text field does not focus and cannot be edited

      ---------- BEGIN SOURCE ----------
      public class HelloApplication extends Application {
          @Override
          public void start(Stage stage) {
              JPanel panel = new JPanel(new GridLayout(3, 1));
              panel.add(new JTextField("Field 1", 20));
              panel.add(new JTextField("Field 2", 20));
              panel.add(new JButton("Button"));

              JPanel panel2 = new JPanel(new GridLayout(3, 1));
              panel2.add(new JTextField("Field 3", 20));
              panel2.add(new JTextField("Field 4", 20));
              panel2.add(new JButton("Button2"));

              Tab tab1 = new Tab("works?");
              SwingNode swingNode = new SwingNode();
              swingNode.setContent(panel);
              tab1.setContent(swingNode);

              Tab tab2 = new Tab("not works");
              SwingNode swingNode2 = new SwingNode();
              swingNode2.setContent(panel2);
              tab2.setContent(swingNode2);

              TabPane pane = new TabPane(tab1, tab2);

              Scene scene = new Scene(pane, 320, 240);
              stage.setTitle("FX Bug?");
              stage.setScene(scene);
              stage.show();
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      The text fields in the first tab can be activated using TAB key, but not with the mouse after the second tab has been activated previously. I have not found a way to activate the text fields in the second tab.

      FREQUENCY : always


        1. bug_recording.mkv
          2.52 MB
          Anupam Dev
        2. HelloApplication.java
          1 kB
          Anupam Dev

            psadhukhan Prasanta Sadhukhan
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: