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

[ComboBox] onAction called twice in an editable ComboBox

    XMLWordPrintable

Details

    Description

      This bug appears in the current early access release of JDK 8 (b126) and also in the previous one.

      Minimal code to reproduce the issue:

      import javafx.application.Application;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Scene;
      import javafx.scene.control.ComboBox;
      import javafx.stage.Stage;

      public class Test extends Application
      {
      public static void main(String[] args)
      {
      launch(args);
      }

      @Override
      public void start(Stage primaryStage) throws Exception
      {
      final ComboBox<String> cb = new ComboBox<String>();
      cb.setEditable(true);
      cb.setOnAction(new EventHandler<ActionEvent>()
      {
      int counter = 0;
      @Override
      public void handle(ActionEvent event)
      {
      System.out.println(counter++);
      }
      });
      primaryStage.setScene(new Scene(cb));
      primaryStage.show();
      }
      }

      Run and type something text in the ComboBox text field, then press Enter. The OnAction event handler gets called twice (two numbers appear in the console).

      Attachments

        Activity

          People

            jgiles Jonathan Giles
            jsmucrjfx Jan Smucr (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: