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

[ComboBox] onActionEvent is not called, when value is set using unidirectional binding.

    XMLWordPrintable

    Details

      Description

      You could see it on attached movie.

      And you can use the next code:


      import javafx.application.Application;
      import javafx.event.Event;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.*;
      import javafx.scene.layout.Pane;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class Issue3 extends Application {

          public static void main(String[] args) {
              launch(args);
          }
          final ComboBox<String> testedComboBox = new ComboBox<String>();

          @Override
          public void start(Stage stage) throws Exception {
              Pane pane = new Pane();
              pane.setPrefHeight(200);
              pane.setPrefWidth(200);

              pane.getChildren().add(testedComboBox);

              testedComboBox.setVisibleRowCount(5);

              testedComboBox.setOnAction(new EventHandler() {

                  public void handle(Event t) {
                      System.out.println(testedComboBox.getValue());
                  }
              });

              TextField tf = new TextField();
              //testedComboBox.valueProperty().bindBidirectional(tf.textProperty());
              testedComboBox.valueProperty().bind(tf.textProperty());

              VBox vb = new VBox();
              vb.getChildren().addAll(pane, tf);
              Scene scene = new Scene(vb, 400, 400);
              stage.setScene(scene);
              stage.show();
          }
      }


      Comment/uncomment according lines about binding to tf.textFieldProperty.
      You could see difference in calling onAction on adding each symbol for bidirectional and unidirectional bindings:
      bidirectional: listener is called for each symbol.
      unidirectional: listener is not called.

        Attachments

        1. rt20103.patch
          1 kB
          Jonathan Giles

          Activity

            People

            Assignee:
            jgiles Jonathan Giles
            Reporter:
            akirov Alexander Kirov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: