• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Numeric/Alphabetic chars

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does the JDK have anything in the API for determining numeric vs. alpabetic characters? In my client, I prevent the user from typing anything but numbers for the fields that require numbers. But I do this by manually running through a string array of numbers (0 - 9) and checking each character typed via a KeyListener. If the character typed is not a numeric, then the KeyEvent is consumed. It works fine functionally, but is there anything in the JDK that would decipher numeric from alphabetic characters for me? I have not seen anything that would do this.
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David,

If you want only to allow certain strings as valid input to a textfield, the standard way to achieve that, would be to use a JFormattedTextField with an appropriate AbstractFormatter-subclass or a Format-subclass.

Frans.
 
Author
Posts: 144
5
jQuery Eclipse IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you use a regular expression? Is using java.util.regex allowed on the SCJD? I have used regular expressions for stuff like this numerous times.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic