Anyone knows how to only allow characters in a JtextField not strings or digits? any example source code will be appreciated.
nilay84 0 Newbie Poster
Recommended Answers
Jump to PostWhat does "only characters... not strings" mean?
but whatever, here's one way
http://www.devx.com/tips/Tip/14311and the intro to the JavaDoc for JTextField shows another way - this one is an officially-approved approach
Jump to PostAnyone knows how to only allow characters in a JtextField not strings or digits? any example source code will be appreciated.
see this:http://www.daniweb.com/software-development/java/threads/73050 what you should get from this is there is only two ways, either wait until all text has been entered and then check to make sure …
Jump to Post"there is only 2 ways"...
there's always another way...the one in JTextField's JavaDoc is neither of those (it extends the default model), but has the official stamp of approval.
Jump to Post"there is only 2 ways"...
there's always another way...the one in JTextField's JavaDoc is neither of those (it extends the default model), but has the official stamp of approval.
lol yes yes sorry i wasnt thinking when i typed, but ofcourse there is more thanks for letting the OP …
Jump to Postoh it means that i should accept a b but not bd fg
why not have a simple check like so:
String text=jTextField1.getText(); if(text.length()>1) { System.out.println("this is not allowed"); jTextField1.setText(""); } else { .... }
All 21 Replies
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
DavidKroukamp 105 Master Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
nilay84 0 Newbie Poster
DavidKroukamp 105 Master Poster Team Colleague Featured Poster
DavidKroukamp 105 Master Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
nilay84 0 Newbie Poster
nilay84 0 Newbie Poster
DavidKroukamp 105 Master Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
nilay84 0 Newbie Poster
DavidKroukamp 105 Master Poster Team Colleague Featured Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
nilay84 0 Newbie Poster
DavidKroukamp 105 Master Poster Team Colleague Featured Poster
nilay84 0 Newbie Poster
DavidKroukamp 105 Master Poster Team Colleague Featured Poster
nilay84 0 Newbie Poster
JamesCherrill 4,733 Most Valuable Poster Team Colleague Featured Poster
DavidKroukamp commented: not a prob man +6
DavidKroukamp 105 Master 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.