I am looking to filter a name field to verify that no numbers have been placed
in the text field. Simple syntax on how to check the string for numbers???
Thanks,
Jason
Printable View
I am looking to filter a name field to verify that no numbers have been placed
in the text field. Simple syntax on how to check the string for numbers???
Thanks,
Jason
The following text is extracted from the Java Manual, you can filter what
you like:
Customized fields can easily be created by extending the model and changing
the default model provided. For example, the following piece of code will
create a field that holds only upper case characters. It will work even if
text is pasted into from the clipboard or it is altered via programmatic
changes.
public class UpperCaseField extends JTextField {
public UpperCaseField(int cols) {
super(cols);
}
protected Document createDefaultModel() {
return new UpperCaseDocument();
}
static class UpperCaseDocument extends PlainDocument {
public void insertString(int offs, String str, AttributeSet a)
throws BadLocationException {
if (str == null) {
return;
}
char[] upper = str.toCharArray();
for (int i = 0; i < upper.length; i++) {
upper[i] = Character.toUpperCase(upper[i]);
}
super.insertString(offs, new String(upper), a);
}
}
}
"Jason" <java.@127.0.0.1> ¼¶¼g©ó¶l¥ó news:3cbc80b3$1@10.1.10.29...
>
> I am looking to filter a name field to verify that no numbers have been
placed
> in the text field. Simple syntax on how to check the string for
numbers???
>
> Thanks,
> Jason