jalvafx library:
The solution is to prevent the user from typing incorrectly. Only 0-9, coma and dot symbols allowed. You can set the minimum and maximum value of the number.

How to use the signature:
TableViewUtils.setEditNumberCellFactory( TableColumn<T, K> cell, BiConsumer<T, Double> changeHandler, String editControlHeader, Double minAllowedValue, Double maxAllowedValue, Function<T, Boolean> ignoreEdit)
Table layout:
TableView<String> tableView = new TableView<>(); tableView.getItems().addAll("USA", "Canada", "Brazil"); TableColumn<String, String> country = new TableColumn<>("Country"); TableColumn<String, Integer> column = new TableColumn<>("Some value"); tableView.getColumns().add(country); tableView.getColumns().add(column); country.setCellValueFactory( data -> new SimpleObjectProperty<>(data.getValue())); column.setCellValueFactory( data -> new SimpleObjectProperty<>(800));
Decision:
BiConsumer<String, Double> changeHandler = (item, newValue) -> { System.out.println("New value is " + newValue); // Your code }; Function<String, Boolean> ignoreEdit = item -> item.equalsIgnoreCase("USA"); TableViewUtils.setEditNumberCellFactory(column, changeHandler, "New value:", 200.0, 800.0, ignoreEdit);
alex valuiskyi
source share