You may run attached code:
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
/**
* @author Alexander Kirov
*/
public class Issue4 extends Application {
public static void main(String[] args) {
launch(args);
}
final ComboBox<String> testedComboBox = new ComboBox<String>();
static int counter = 0;
@Override
public void start(Stage stage) throws Exception {
VBox pane = new VBox();
pane.setPrefHeight(200);
pane.setPrefWidth(200);
testedComboBox.setEditable(true);
testedComboBox.getItems().addAll("1", "2", "3");
VBox vb = new VBox();
pane.getChildren().addAll(testedComboBox);
testedComboBox.setOnAction(new EventHandler<ActionEvent>(){
public void handle(ActionEvent t) {
System.out.println("Is called");
}
});
vb.getChildren().addAll(pane);
Scene scene = new Scene(vb, 400, 400);
stage.setScene(scene);
stage.show();
}
}
Steps to reproduce:
type "a";
press Enter;
I see in output:
run:
Is called
Is called
But I expect only one call.
You may see issue on attached image.
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.ComboBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
/**
* @author Alexander Kirov
*/
public class Issue4 extends Application {
public static void main(String[] args) {
launch(args);
}
final ComboBox<String> testedComboBox = new ComboBox<String>();
static int counter = 0;
@Override
public void start(Stage stage) throws Exception {
VBox pane = new VBox();
pane.setPrefHeight(200);
pane.setPrefWidth(200);
testedComboBox.setEditable(true);
testedComboBox.getItems().addAll("1", "2", "3");
VBox vb = new VBox();
pane.getChildren().addAll(testedComboBox);
testedComboBox.setOnAction(new EventHandler<ActionEvent>(){
public void handle(ActionEvent t) {
System.out.println("Is called");
}
});
vb.getChildren().addAll(pane);
Scene scene = new Scene(vb, 400, 400);
stage.setScene(scene);
stage.show();
}
}
Steps to reproduce:
type "a";
press Enter;
I see in output:
run:
Is called
Is called
But I expect only one call.
You may see issue on attached image.