File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes cant figure this out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "cant figure this out" Watch "cant figure this out" New topic

cant figure this out

khella smith
Ranch Hand

Joined: May 06, 2002
Posts: 39
u have a textfield and u only want it to take strictly alphabets as strings and u have to get the name from this field and compare it before determining if it is all alphabets cause u dont want it to take numbers.if u get the text from the textfield what do u compare it to to ensure that this condition is true and if it is false i want it to display an error message saying u are only allowed to use alphabets for this kind of field.i know how to display the message but what do i compare the name from the textfield with to ensure that the condition is true? i cant seem to figure it out
i appreciate an answer
khella smith
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
You can use the following methods of the Character class. isDigit(), isLetter(), etc. You want to loop through each character in your string and to the check you need to do. Check the API for more info.

So much trouble in the world -- Bob Marley
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
TextField or JTextField? The solution depends on which.
khella smith
Ranch Hand

Joined: May 06, 2002
Posts: 39
its JTextField
I agree. Here's the link:
subject: cant figure this out
It's not a secret anymore!