java - How to use JFormattedTextField to allow only alphabets? -
i searched solution everywhere, found solutions allowing numbers, alphanumeric (using documentfilter
).
but, need allow alphabets , intend use jformattedtextfield
due advantages.
so, how use jformattedtextfield
allow alphabets (a-za-z) (no space, punctuation, letters)!
since number variable, , if i'm not wrong jformattedtextfield uses masks fixed length of digits, more easy use litener change text event , validate text in element removing unallowed characters.
something that:
jtextfield f = null; f.getdocument().adddocumentlistener(new documentlistener() { @override public void insertupdate(documentevent e) { validateinputtext(); } @override public void removeupdate(documentevent e) { validateinputtext(); } @override public void changedupdate(documentevent e) { validateinputtext(); } });
Comments
Post a Comment