posto DocumenControl già è stata una nostra discussione...
codice:
public class DocumenControl extends PlainDocument {
private final String expRegular;
private final JTextField jtf;
public DocumenControl(String exp, JTextField jtf) {
expRegular = exp;
this.jtf=jtf;
}
public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
String tmp="";
tmp=jtf.getText()+str;
if(str!=null && tmp.matches(expRegular))
super.insertString(offs, str, a);
}
public JTextField getJtf() {
return jtf;
}
}
tcm non va nel senso che la regola dell'espressione mi vale per tutte le celle...