JFormattedTextField validation

Hi Freinds,I want to validate input in JFormattedTextField while user types in that.Meant to say it only allows user to input number, not text. How can i do this?Thanx
[195 byte] By [Jchefa] at [2007-10-3 4:35:14]
# 1
Add a MaskFormatter to the formatted text field.
camickra at 2007-7-14 22:38:57 > top of Java-index,Desktop,Core GUI APIs...
# 2

I used below code, in JFormattedTextField's KeyTyped event:

char KeyVal = evt.getKeyChar();

if (KeyVal >= 48 && KeyVal <= 57 || KeyVal ==8) { /* Do nothing */ }

else {

KeyVal = 0;

evt.setKeyChar((char)KeyVal);

}

It works properly.

Thanx.

JChef

Jchefa at 2007-7-14 22:38:57 > top of Java-index,Desktop,Core GUI APIs...