Skip to content
Snippets Groups Projects
Commit db02660d authored by Magnus Eik's avatar Magnus Eik
Browse files

Use Formatter instead of regex in AbstractPopup.

parent 7692177c
No related branches found
No related tags found
No related merge requests found
package edu.ntnu.stud.chaosgame.view.modificationpopups;
import edu.ntnu.stud.chaosgame.controller.utility.Formatter;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
......@@ -13,6 +14,8 @@ import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import java.text.Normalizer;
/**
* Abstract class for popups.
*/
......@@ -129,13 +132,9 @@ public abstract class AbstractPopup {
* @return the numeric text field.
*/
protected TextField createNumericTextField() {
TextField textField = new TextField();
textField.textProperty().addListener((observable, oldValue, newValue) -> {
if (!newValue.matches("-?\\d*(\\.\\d*)?")) { // TODO: replace with Formatter
textField.setText(oldValue);
}
});
return textField;
TextField numberField = new TextField();
numberField.setTextFormatter(Formatter.getFloatFormatter());
return numberField;
}
/**
......
Affine2D
Heighway-Dragon
-1.0, -1.0
1.5, 1.5
0.8, -0.3, 0.5, 0.5, 0.0, 0.0
-0.5, -0.5, 0.6, -0.6, 1.0, 0.0
Julia
Julia2
-1.6, -1.0
1.6, 1.0
-0.8, 0.8
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment