diff options
Diffstat (limited to 'src/jcgp/gui/settings/parameters')
-rw-r--r-- | src/jcgp/gui/settings/parameters/GUIDoubleParameter.java | 10 | ||||
-rw-r--r-- | src/jcgp/gui/settings/parameters/GUIIntegerParameter.java | 4 | ||||
-rw-r--r-- | src/jcgp/gui/settings/parameters/GUIParameter.java | 2 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java index 5331364..f177ffa 100644 --- a/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIDoubleParameter.java @@ -32,13 +32,13 @@ public class GUIDoubleParameter extends GUIParameter<Number> { */ GUIDoubleParameter(Parameter<Number> parameter, SettingsPane sp) { super(parameter, sp); - decimalFormat = new DecimalFormat(); - decimalFormat.setMaximumFractionDigits(10); } @Override protected Control makeControl() { - textField = new TextField(String.valueOf(parameter.get())); + decimalFormat = new DecimalFormat(); + decimalFormat.setMaximumFractionDigits(10); + textField = new TextField(decimalFormat.format(parameter.get().doubleValue())); textField.setStyle(VALID_PARAMETER_STYLE); textField.setAlignment(Pos.CENTER_RIGHT); textField.prefWidthProperty().bind(widthProperty().divide(2)); @@ -100,6 +100,8 @@ public class GUIDoubleParameter extends GUIParameter<Number> { @Override public void refreshValue() { - textField.setText(decimalFormat.format(parameter.get().doubleValue())); + if (!textField.isFocused()) { + textField.setText(decimalFormat.format(parameter.get().doubleValue())); + } } } diff --git a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java index ee266f3..e1b0b75 100644 --- a/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIIntegerParameter.java @@ -97,6 +97,8 @@ public class GUIIntegerParameter extends GUIParameter<Number> { @Override public void refreshValue() { - textField.setText(String.valueOf(parameter.get())); + if (!textField.isFocused()) { + textField.setText(String.valueOf(parameter.get())); + } } } diff --git a/src/jcgp/gui/settings/parameters/GUIParameter.java b/src/jcgp/gui/settings/parameters/GUIParameter.java index c6ac2e6..79762ff 100644 --- a/src/jcgp/gui/settings/parameters/GUIParameter.java +++ b/src/jcgp/gui/settings/parameters/GUIParameter.java @@ -141,7 +141,7 @@ public abstract class GUIParameter<T> extends HBox { ObservableValue<? extends Object> observable, Object oldValue, Object newValue) { // only do this if the experiment is running - if (settingsPane.isExperimentRunning()) { + if (settingsPane.isExperimentRunning() || !isFocused()) { /* here's the catch - atomically get the lock state and set it to true * the lock will only be false again when the runnable is finished executing, * preventing multiple runnables to concurrently update the same GUIParameter |