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

[TextField] onAction is not applied.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • fx2.1
    • fx2.1
    • javafx
    • 2.1b06

    Description

      Code:


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

      /**
       *
       * @author alexandr_kirov
       */
      public class JavaFX_TextField_OnActionListener extends Application {

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

          @Override
          public void start(Stage stage) throws Exception {
              final TextField tf = new TextField();

              Button setOnActionListenerButton = ButtonBuilder.create().text("Set on action listener").build();
              setOnActionListenerButton.setOnAction(new EventHandler() {

                  @Override
                  public void handle(Event t) {
                      tf.onActionProperty().setValue(new EventHandler<ActionEvent>() {

                          @Override
                          public void handle(ActionEvent t) {
                              System.out.println("A");
                          }
                      });
                  }
              });

              VBox pane = new VBox();
              pane.getChildren().addAll(tf, setOnActionListenerButton);

              Scene scene = new Scene(pane, 300, 300);
              stage.setScene(scene);
              stage.show();
          }
      }

      Steps to reproduce:
      Click on button and make some actions on textField. You can see no affect.

      Attachments

        Activity

          People

            leifs Leif Samuelsson (Inactive)
            akirov Alexander Kirov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: