You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
599 B
36 lines
599 B
package com.olexyn.ensync;
|
|
|
|
import javafx.util.converter.DoubleStringConverter;
|
|
|
|
public class MyDoubleStringConverter extends DoubleStringConverter {
|
|
|
|
@Override
|
|
|
|
public Double fromString(final String value) {
|
|
|
|
return value.isEmpty() || !isNumber(value) ? null :
|
|
|
|
super.fromString(value);
|
|
|
|
}
|
|
|
|
public boolean isNumber(String value) {
|
|
|
|
int size = value.length();
|
|
|
|
for (int i = 0; i < size; i++) {
|
|
|
|
if (!Character.isDigit(value.charAt(i))) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return size > 0;
|
|
|
|
}
|
|
|
|
}
|