///expressão regular para controlar o IP valido
String _255 = "(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)";
Pattern p = Pattern.compile("^(?:" + _255 + "\\\\.){3}" + _255 + "$");
RegexFormatter ipFormatter = new RegexFormatter(p);
txtip.setFormatterFactory(new DefaultFormatterFactory(ipFormatter));