@Override
public Vote previewInsertText(TextInput textInput, CharSequence text, int index) {
Vote vote = Vote.APPROVE;
if (textInput.isStrictValidation()) {
Validator validator = textInput.getValidator();
if (validator != null) {
StringBuilder textBuilder = new StringBuilder();
textBuilder.append(textInput.getText(0, index));
textBuilder.append(text);
textBuilder.append(textInput.getText(index, textInput.getCharacterCount()));
if (!validator.isValid(textBuilder.toString())) {
vote = Vote.DENY;
Toolkit.getDefaultToolkit().beep();
}
}
}