I have a TextArea that I am trying to restrict user inputs to allow only IP addresses format in that Area. So I thought of only allowing digits and decimal points. For multiple IPs, One IP per line, the TextArea needs to accept new lines. For the most part what I have below is working except for delete. I can't delete any entry even if I am using the associate Unicode. Is this even the correct way of doing it?
public class RestrictIpInputTextArea extends TextArea {
@Override
public void replaceText(int i, int il, String string){
if(string.matches("[0-9_\\u000A_\\u232B_\\u0008_\\u2421_._\\u007F_\\u005F]") || string.isEmpty()){
super.replaceText(il, il, string);
}
}
@Override
public void replaceSelection(String string) {
super.replaceSelection(string);
}
}
In my FXML File I calling it as <RestrictIpInputTextArea ......