Skip to content

Commit ca2509e

Browse files
DSheirerDennis Sheirer
andauthored
#1854 Tuner minimum frequency of 1 Hertz now supported. Resolves issue where the FrequencyTextField wouldn't accept minimum frequency values smaller than 1 MHz on initial setup. (#1855)
Co-authored-by: Dennis Sheirer <[email protected]>
1 parent 1d2ba8c commit ca2509e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/main/java/io/github/dsheirer/gui/control/FrequencyTextField.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@
3838
public class FrequencyTextField extends JTextField
3939
{
4040
private static final Logger LOGGER = LoggerFactory.getLogger(FrequencyTextField.class);
41-
private static final String REGEX = "[1-9][0-9]{0,3}(\\.[0-9]{0,6})?";
41+
//Value range: 0.000001 to 9999.999999
42+
private static final String REGEX = "^[0-9]{0,4}[.]?[0-9]{0,6}$";
43+
//This lets users start typing a really small number like 1 Hertz ... 0.00000
44+
private static final String ZEROS_REGEX = "^0?([.]0{0,5})?$";
4245
private double mMinimum;
4346
private double mMaximum;
4447

@@ -110,7 +113,7 @@ public void setFrequency(long frequency)
110113
*/
111114
private boolean isValid(String value)
112115
{
113-
if(value == null || value.isEmpty())
116+
if(value == null || value.isEmpty() || value.matches(ZEROS_REGEX))
114117
{
115118
return true;
116119
}
@@ -183,7 +186,7 @@ public static void main(String[] args)
183186
{
184187
JFrame frame = new JFrame("Frequency Control Test");
185188
frame.setSize(300, 200);
186-
FrequencyTextField ftf = new FrequencyTextField(20, 2_000_000_000, 101_100_000);
189+
FrequencyTextField ftf = new FrequencyTextField(1, 9_999_999_999l, 101_100_000);
187190
frame.setLayout(new MigLayout());
188191
frame.add(ftf);
189192

src/main/java/io/github/dsheirer/source/tuner/ui/TunerEditor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public abstract class TunerEditor<T extends Tuner,C extends TunerConfiguration>
6767
implements IDiscoveredTunerStatusListener, Listener<TunerEvent>
6868
{
6969
private Logger mLog = LoggerFactory.getLogger(TunerEditor.class);
70-
private static final long DEFAULT_MINIMUM_FREQUENCY = 1_000_000;
70+
private static final long DEFAULT_MINIMUM_FREQUENCY = 1;
7171
private static final long DEFAULT_MAXIMUM_FREQUENCY = 9_999_999_999l;
7272
private static final String BUTTON_STATUS_ENABLE = "Enable";
7373
private static final String BUTTON_STATUS_DISABLE = "Disable";

0 commit comments

Comments
 (0)