Author
help wanted
david hu
Ranch Hand
Joined: Jul 20, 2001
Posts: 143
How to check whether the string entered in the text field is consisted of only digit letters
Valentin Crettaz
Gold Digger
Sheriff
Joined: Aug 26, 2001
Posts: 7610
you can maybe try to convert it to a number and if no NumberFormatException is thrown then there are only digits. Another method is to check if every character of the String is a digit or not HIH ------------------ Valentin Crettaz Sun Certified Programmer for Java 2 Platform
SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Maulin Vasavada
Ranch Hand
Joined: Nov 04, 2001
Posts: 1865
posted Nov 17, 2001 01:21:00
0
hi david, it's easy.. just implement KeyListener on the text field and on each ket stroke check the "keyChar" property of the KeyEvent using getKeyChar() method. check it is between 0-9 and you are done. regards, maulin.
1. Have fun @ http://faq.javaranch.com/java/JavaRaq
2. Looking for simple infix2postfix conversion and postfix evaluation package? Click here
subject: help wanted