I have four JTextFields where user is allowed to enter only numbers.
Question is how do I do this?
peter_budo
2,532
Code tags enforcer
Team Colleague
Featured Poster
Recommended Answers
Jump to PostYou could use the keypressed event handler
http://java.sun.com/docs/books/tutorial/uiswing/events/keylistener.html
or wait till the user enters the entire lot then parse it at the end returning either a success or fail message.
Jump to PostYou could use component like a dropdown box to limit the users choices to a range of numbers.
Jump to PostI think that limiting user input is always good.
How about the JSpinner class. That should allow the user to input a large range of numbers (that you specify in the constructor).
All 9 Replies
iamthwee
peter_budo
2,532
Code tags enforcer
Team Colleague
Featured Poster
Cerberus
17
Junior Poster
peter_budo
2,532
Code tags enforcer
Team Colleague
Featured Poster
Cerberus
17
Junior Poster
titaniumdecoy
58
Light Poster
peter_budo
2,532
Code tags enforcer
Team Colleague
Featured Poster
PupuPlatter
0
Newbie Poster
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.