I need to restrict input to only integers in an editable ComboBox. In other words, so that the user can input only digits 0-9
, for example 1023
. This is what I have:
public class JavaFxTest7 extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
ComboBox<Integer> comboBox = new ComboBox<>();
comboBox.getItems().addAll(1, 2, 3);
comboBox.setEditable(true);
Scene scene = new Scene(new VBox(comboBox), 200, 100);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Could anyone say how to do it?