1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
class MyRenderer extends DefaultTreeCellRenderer {
public MyRenderer() {
}
@Override
public Component getTreeCellRendererComponent(
JTree tree,
Object value,
boolean sel,
boolean expanded,
boolean leaf,
int row,
boolean hasFocus) {
super.getTreeCellRendererComponent(
tree, value, sel,
expanded, leaf, row,
hasFocus);
Pattern pattern;
Matcher matcher;
pattern = Pattern.compile("^([0-9]{1,3}\\.){3}[0-9]{1,3}$"); //regex ip address ([0-9]{1,3}\\.){3}[0-9]{1,3}
matcher = pattern.matcher(value.toString());
if (matcher.find()) {
System.out.println("OK");
setBackground(Color.green);
}
System.out.println("SORTIE");
return this;
}
} |
Partager