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

Calling "setSelected(true)" on CheckBox fires ActionEvent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 7u6
    • 7u6
    • javafx
    • WinXP, Java 7, JavaFX 2.2 (b14)

      Calling "setSelected(true)" on CheckBox instance fires ActionEvent associated with this CheckBox. Example below prints "Triggered!". This behaviour was not present in JavaFX 2.2 (b4) and concerns only the first "setSelected(true)" call.

      CheckBox checkBox = new CheckBox();
      checkBox.setOnAction(new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
              System.out.println("Triggered!");
          }
      });
      checkBox.setSelected(true);

      EDIT: Also, suppressing implicit selection switch doesn't work. The following example causes stack overflow when CheckBox is clicked.

      final CheckBox checkBox = new CheckBox();
      checkBox.setOnAction(new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
              checkBox.setSelected(!checkBox.isSelected());
          }
      });

            kwwong Kinsley Wong (Inactive)
            svolfjfx Stepan Volf (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: