/**
* Sets the error text to display if the value is not a valid number. For example, this can happen if a valid character like '.' or '-' is left in the field
* with no number (defaults to "{value} is not a valid number").
*
* @param nanText the not a number text
*/
public void setNanText(String nanText) {
this.nanText = nanText;
}

// Attempt to only allow 1 non-digit in the value (ie. '.' or ',').
// Add some bogus value to the end so we are able to split the string properly if the latestKey is a non-digit.
// Otherwise we won't get the right number of tokens.
String splitString = rawValue + latestKey + "9";
String[] tokens = splitString.split("\\D"); // Split the string on non-digits.
// Attempt to see if there is already an allowed non-digit within the rawValue, as we only want to have 1.
if (tokens.length > 2 && rawValue.indexOf(key) != -1) {
// Stop the 2nd non-digit key from being allowed.
fe.stopEvent();
return;
}

// Preview what the value is going to look like, and determine if we should allow it.
final StringBuilder sb = new StringBuilder(rawValue);
sb.insert(cursorPos, latestKey); // Add latestKey in the right position.

String previewValue = sb.toString();
// Determine if there is a decimal and that the length of it doesn't exceed 'decimalPrecision'.
if (previewValue.length() > 0) {
tokens = previewValue.split("\\D"); // Split the string on non-digits.
if (tokens.length > 1) {
// A decimal was found.
String decimal = tokens[1];
if (decimal.length() > decimalPrecision) {
// The decimal length is longer than we want.
if (rawValueLength > cursorPos) { // Optional check.
// The inserted value is not at the end. Allow the value, but remove the last character
// to keep the proper length.
String newValue = previewValue.substring(0, previewValue.length() - 1);
setRawValue(newValue); // This moves the cursor to the end of the field.
setCursorPos(cursorPos + 1); // Move the cursor back to the next position.
}
fe.stopEvent();
}
}
}
}

I changed the 'maxNumberCharactersAfterDecimalSeparator' variable to 'decimalPrecision'.