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

Calling "setSelected(true)" on CheckBox fires ActionEvent

    Details

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

      WinXP, Java 7, JavaFX 2.2 (b14)

      Description

      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());
          }
      });

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: