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

Focus traversal is broken if a Pane is added to a ToolBar

XMLWordPrintable

    • generic
    • generic

      FULL PRODUCT VERSION :
      java version "9.0.1"
      Java(TM) SE Runtime Environment (build 9.0.1+11)
      Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux gao 4.13.0-21-generic #24-Ubuntu SMP Mon Dec 18 17:29:16 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      When a Pane that contains a Button is added to a ToolBar, pressing the TAB key while that Button is in focus will put the focus to the component that comes after the ToolBar rather than the next component after the Pane in the ToolBar.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the following JavaFX application:

      ==========8<==========Foo.java==========
      import javafx.application.Application;
      import javafx.fxml.FXMLLoader;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.stage.Stage;

      public class Foo extends Application {
          @Override
          public void start(Stage stage) throws Exception{
              Parent root = FXMLLoader.load(getClass().getResource("Foo.fxml"));
              stage.setTitle("Keyboard Navigation");
              stage.setScene(new Scene(root));
              stage.show();
          }
      }
      ==========8<==========

      with the following FXML file:
      ==========8<==========Foo.fxml==========
      <?xml version="1.0" encoding="UTF-8"?>

      <?import javafx.scene.control.Button?>
      <?import javafx.scene.control.ToolBar?>
      <?import javafx.scene.layout.HBox?>
      <?import javafx.scene.layout.Pane?>
      <HBox>
          <Button text="Before"/>
          <ToolBar>
              <Button text="Foo"/>
              <Pane>
                  <Button text="Bar"/>
              </Pane>
              <Pane>
                  <Button text="Baz"/>
              </Pane>
              <Pane>
                  <Button text="Quux"/>
              </Pane>
              <Button text="Quuux"/>
          </ToolBar>
          <Button text="After"/>
      </HBox>
      ==========8<==========

      And start pressing the TAB key to traverse the components.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      For TAB, the components are traversed in the order:

        Before, Foo, Bar, Baz, Quux, Quuux, After

      Foo Alt-TAB, the components are traversed in the reverse order:

        After, Quuux, Quux, Baz, Bar, Foo, Before
      ACTUAL -
      For TAB, the components are traversed in the order:

        Before, Foo, Bar, After

      For Alt-TAB, the components are traversed in the order:

        After, Quuux, Quux, Before

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Run the following JavaFX application:

      ==========8<==========Foo.java==========
      import javafx.application.Application;
      import javafx.fxml.FXMLLoader;
      import javafx.scene.Parent;
      import javafx.scene.Scene;
      import javafx.stage.Stage;

      public class Foo extends Application {
          @Override
          public void start(Stage stage) throws Exception{
              Parent root = FXMLLoader.load(getClass().getResource("Foo.fxml"));
              stage.setTitle("Keyboard Navigation");
              stage.setScene(new Scene(root));
              stage.show();
          }
      }
      ==========8<==========

      with the following FXML file:
      ==========8<==========Foo.fxml==========
      <?xml version="1.0" encoding="UTF-8"?>

      <?import javafx.scene.control.Button?>
      <?import javafx.scene.control.ToolBar?>
      <?import javafx.scene.layout.HBox?>
      <?import javafx.scene.layout.Pane?>
      <HBox>
          <Button text="Before"/>
          <ToolBar>
              <Button text="Foo"/>
              <Pane>
                  <Button text="Bar"/>
              </Pane>
              <Pane>
                  <Button text="Baz"/>
              </Pane>
              <Pane>
                  <Button text="Quux"/>
              </Pane>
              <Button text="Quuux"/>
          </ToolBar>
          <Button text="After"/>
      </HBox>
      ==========8<==========

      And start pressing the TAB key to traverse the components.
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      There seems to be no way to reach Baz through keyboard navigation.

        1. Foo.fxml
          0.6 kB
        2. Foo.java
          0.5 kB

            aghaisas Ajit Ghaisas
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: