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

A button with setDefaultButton(true) consumes Enter event, even when it is disabled.

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: fx2.1
    • Fix Version/s: 7u6
    • Component/s: javafx
    • Environment:

      Windows 7, JavaFX beta 2.1 b13

      Description

      A button with setDefaultButton(true) consumes Enter event, even when it is disabled.

      I feel this is incorrect behavior. If I (as a developer) disable a button I want to prevent the user to use it (either by click or by keyboard).


      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class TestApp3 extends Application {

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

          public void start(final Stage stage) throws Exception {

              VBox root = new VBox();


              Button button = new Button("close");
              button.setOnAction(new EventHandler<ActionEvent>() {
                  @Override
                  public void handle(ActionEvent actionEvent) {
                      stage.close();
                  }
              });

              button.setDefaultButton(true);
              button.setDisable(true);
              root.getChildren().addAll(button);

              Scene scene = new Scene(root);
              stage.setScene(scene);
              stage.show();
          }
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kwwong Kinsley Wong
                Reporter:
                cschudtjfx Christian Schudt (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: