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

Focus Traversal broken in ScrollPane

    Details

      Description

      When focusTraversal is set to false and reset to true the focus cycle is broken. In the test below only button1 can receive the focus after setting focus traversal to false and resetting to true.

      public class FocusTraversableTest extends Application
      {
        private Button button1;
        private Button button2;
        private Button button3;
        
        public static void main(String[] args)
        {
          Application.launch(args);
        }

        @Override
        public void start(Stage stage)
        {
          FlowPane root = new FlowPane(10, 10);
          ButtonPane buttonPane = new ButtonPane();
          TabPane tabPane = new TabPane();

          Tab tab = new Tab("Buttons");
          tab.setContent(buttonPane);
          tabPane.getTabs().add(tab);
          root.getChildren().add(tabPane);
          
          CheckBox cb = new CheckBox("Focus traversable");
          cb.setOnAction(new EventHandler<ActionEvent>()
          {
            @Override
            public void handle(ActionEvent event)
            {
              CheckBox cb = (CheckBox)event.getSource();
              boolean traversable = cb.isSelected();
              button1.setFocusTraversable(traversable);
              button2.setFocusTraversable(traversable);
              button3.setFocusTraversable(traversable);
            }
          });
          cb.setSelected(true);
          root.getChildren().add(cb);
          
          Scene scene = new Scene(root, 800, 600);
          stage.setScene(scene);
          stage.show();
        }
        
        private class ButtonPane extends ScrollPane
        {
          public ButtonPane()
          {
            VBox vbox = new VBox(10);
            button1 = new Button("Button1");
            vbox.getChildren().add(button1);
            button2 = new Button("Button2");
            vbox.getChildren().add(button2);
            button3 = new Button("Button3");
            vbox.getChildren().add(button3);

            setContent(vbox);
          }
        }
      }

        Attachments

          Activity

            People

            • Assignee:
              jgiles Jonathan Giles
              Reporter:
              wzberger Wolfgang Zitzelsberger
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: