Can anyone tell me how to use Java Keylistener to add validations in my java gui form??
eg. I have a textfield. I want to enter only alphabets in it. I dont want any numerics. So when a user tries to type a numeric value in it, I want to prompt a message. But how can I have do it in java?
Can use of keylistener be helpful??
Darshan5
0
Newbie Poster
Recommended Answers
Jump to Post
don't use KeyListener for JTextComponents, use DocumentListener,
use JFormattedTextField,
I'd be to use DocumentFilter with Pattern, filtering for non_alphabets chars, then there no needed any prompt about non_number char is inputed,
All 3 Replies
mKorbel
274
Veteran Poster
harinath_2007
56
Posting Whiz
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.