This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cant figure this out

 
khella smith
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
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
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TextField or JTextField? The solution depends on which.
 
khella smith
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
its JTextField
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic