From bc9b26588bfe5ef5861e924efa4e15ff73f1b0c4 Mon Sep 17 00:00:00 2001 From: jprocter Date: Tue, 25 Sep 2012 14:30:00 +0100 Subject: [PATCH] JAL-1010 write validated value back to text field to ensure parameter value is always valid --- src/jalview/gui/OptsAndParamsPage.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/jalview/gui/OptsAndParamsPage.java b/src/jalview/gui/OptsAndParamsPage.java index 05c8e1d..0f6126c 100644 --- a/src/jalview/gui/OptsAndParamsPage.java +++ b/src/jalview/gui/OptsAndParamsPage.java @@ -660,6 +660,8 @@ public class OptsAndParamsPage { } ; + // update value field to reflect any bound checking we performed. + valueField.setText(""+iVal); if (validator.getMin() != null && validator.getMax() != null) { slider.getModel().setRangeProperties(iVal, 1, @@ -678,6 +680,7 @@ public class OptsAndParamsPage fVal = 0f; try { + valueField.setText(valueField.getText().trim()); fVal = Float.valueOf(valueField.getText()); if (validator.getMin() != null && validator.getMin().floatValue() > fVal) @@ -685,6 +688,8 @@ public class OptsAndParamsPage fVal = validator.getMin().floatValue(); // TODO: provide visual indication that hard limit was reached for // this parameter + // update value field to reflect any bound checking we performed. + valueField.setText(""+fVal); } if (validator.getMax() != null && validator.getMax().floatValue() < fVal) @@ -692,6 +697,8 @@ public class OptsAndParamsPage fVal = validator.getMax().floatValue(); // TODO: provide visual indication that hard limit was reached for // this parameter + // update value field to reflect any bound checking we performed. + valueField.setText(""+fVal); } } catch (Exception e) { -- 1.7.10.2