Bounding textField to Numeric or Alphabetic data.....

AOA

How can i bound the JTextField to accept

only numeric data or only alphabetic data

according to my requirement.

I just want that a particular text field

should not take keyboard input other than numeric values.

or it should accept just alphabets in it.

Whats the way to it?

[330 byte] By [@tifa] at [2007-11-26 16:03:45]
# 1
Maybe JFormattedTextfield, definitely with a custom Document.
PhHeina at 2007-7-8 22:25:38 > top of Java-index,Java Essentials,New To Java...
# 2

> AOA

> How can i bound the JTextField to accept

> only numeric data or only alphabetic data

> according to my requirement.

> I just want that a particular text field

> should not take keyboard input other than numeric

> values.

> or it should accept just alphabets in it.

> Whats the way to it?

You can't do this with JTextField

Use JFormattedTextField

JFormattedTextField text1=new JFormattedTextField(new DecimalFormat(String Pattern));

qUesT_foR_knOwLeDgea at 2007-7-8 22:25:38 > top of Java-index,Java Essentials,New To Java...