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

[Focus] if traverse focus in focus change listener, scene will have two focused controls

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 8
    • Fix Version/s: 8
    • Component/s: javafx
    • Labels:
    • Environment:

      8.0b76

      Description

      Run the code:

          @Override
          public void start(Stage stage) throws Exception {
              final TextField tf1 = new TextField("text1"), tf2 = new TextField("text2");
              tf1.focusedProperty().addListener(new ChangeListener<Boolean>() {
                  @Override
                  public void changed(ObservableValue<? extends Boolean> ov, Boolean lostFocus, Boolean getFocus) {
                      if (lostFocus) {
                          tf1.requestFocus();
                      }
                  }
              });
              stage.setScene(new Scene(new VBox(tf1, tf2), 300, 300));
              stage.show();
          }

      Initially, text field 1 has a focus. Press TAB. Both textFields will be focused (visually), but only the first one will receive input, press tab again, and the second control will start to receive keyboard input, but they both will still be visually focused.

      Test case is from : http://stackoverflow.com/questions/14841622/javafx-after-dialog-two-textfields-gains-focus-instead-one

      Situation can be observed here : http://www.fotos-hochladen.net/view/focus2cd7ioyvr3g.png

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                psafrata Pavel Ĺ afrata
                Reporter:
                akirov Alexander Kirov (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: