From b360950b804285a500b133307ef009abf496789b Mon Sep 17 00:00:00 2001 From: Randy Date: Fri, 14 Mar 2025 01:52:49 -0600 Subject: [PATCH] Update IntegerFormatter.java for negative squelch value (#2187) Two issues: (1)documentation for change.getText() says it can be an empty string but never null. (2)Need to allow for typing a minus sign before validating min/max. --- .../io/github/dsheirer/gui/control/IntegerFormatter.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/dsheirer/gui/control/IntegerFormatter.java b/src/main/java/io/github/dsheirer/gui/control/IntegerFormatter.java index 1e013e23..5937417d 100644 --- a/src/main/java/io/github/dsheirer/gui/control/IntegerFormatter.java +++ b/src/main/java/io/github/dsheirer/gui/control/IntegerFormatter.java @@ -85,7 +85,7 @@ public class IntegerFormatter extends TextFormatter public Change apply(Change change) { //Only validate if the user added text to the control. Otherwise, allow it to go through - if(change.getText() != null) + if(!change.getText().equals("")) { String updatedText = change.getControlNewText(); @@ -93,6 +93,12 @@ public class IntegerFormatter extends TextFormatter { return change; } + + // don't validate yet if input is only a minus sign + if(updatedText.equals("-")) + { + return change; + } if(!updatedText.matches(DECIMAL_REGEX) || !isValid(updatedText)) {