Skip to content
Snippets Groups Projects
Commit ed90b112 authored by Philipp Spohr's avatar Philipp Spohr
Browse files

Fix for big numbers in formatted text fields

parent 5cd18cb8
Branches
Tags
No related merge requests found
...@@ -35,6 +35,6 @@ public class DoubleInputField extends JFormattedTextField{ ...@@ -35,6 +35,6 @@ public class DoubleInputField extends JFormattedTextField{
} }
public double getValueAsDouble() { public double getValueAsDouble() {
return Double.parseDouble(getText()); return (double)getValue();
} }
} }
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
package de.hhu.ba.yoshikoWrapper.gui; package de.hhu.ba.yoshikoWrapper.gui;
import javax.swing.JFormattedTextField; import javax.swing.JFormattedTextField;
import javax.swing.text.NumberFormatter;
/** /**
* Provides a more strict input field that only accepts integers * Provides a more strict input field that only accepts integers
...@@ -29,17 +30,23 @@ import javax.swing.JFormattedTextField; ...@@ -29,17 +30,23 @@ import javax.swing.JFormattedTextField;
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class IntegerInputField extends JFormattedTextField{ public class IntegerInputField extends JFormattedTextField{
private final NumberFormatter formatter;
public IntegerInputField(int minValue, int maxValue) { public IntegerInputField(int minValue, int maxValue) {
super(FormatHelper.getIntegerFormatter(minValue,maxValue)); super();
formatter = FormatHelper.getIntegerFormatter(minValue,maxValue);
this.setFormatter(formatter);
this.setColumns(8); this.setColumns(8);
} }
public IntegerInputField() { public IntegerInputField() {
super(FormatHelper.getIntegerFormatter()); super();
formatter = FormatHelper.getIntegerFormatter();
this.setFormatter(formatter);
this.setColumns(8); this.setColumns(8);
} }
public int getValueAsInt() { public int getValueAsInt() {
return Integer.parseInt(getText()); return (int) getValue();
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment