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

Focus couldn't be received or traversed.

    Details

      Description

      Please, observe this code:


      import javafx.application.Application;
      import javafx.beans.value.ChangeListener;
      import javafx.beans.value.ObservableValue;
      import javafx.scene.Scene;
      import javafx.scene.layout.VBox;
      import javafx.scene.paint.Color;
      import javafx.scene.shape.Rectangle;
      import javafx.scene.text.Text;
      import javafx.stage.Stage;

      /**
       * @author alexandr_kirov
       */
      public class NewClass extends Application {

          @Override
          public void start(Stage stage) throws Exception {

              Text text = new Text("text");
              text.setFocusTraversable(true);

              Rectangle r = new Rectangle(100, 100, 100, 100);
              r.setFill(Color.ALICEBLUE);
              r.setFocusTraversable(true);

              text.focusedProperty().addListener(new ChangeListener<Boolean>() {

                  @Override
                  public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
                      System.out.println("Text focused.");
                  }
              });

              r.focusedProperty().addListener(new ChangeListener<Boolean>() {

                  @Override
                  public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) {
                      System.out.println("Rectangle focused.");
                  }
              });

              VBox vb = new VBox();
              vb.getChildren().addAll(r, text);

              Scene scene = new Scene(vb, 300, 300);
              stage.setScene(scene);
              stage.show();
          }

          public static void main(String[] args) {
              launch(args);
          }
      }

      If I set true, I expect navigating between rectangle and text. But I see:
      run-single:
      Rectangle focused.

      and that is all.

      But I don't see blue borders and focus switching.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                miflemi Mick Fleming (Inactive)
                Reporter:
                akirov Alexander Kirov (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: