• Post Reply Bookmark Topic Watch Topic
  • New Topic

numeric textfield  RSS feed

 
Candy Bortniker
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know how to set up a textfield with a format so that the user can see that they need to enter numbers. What I need to do is not allow the user to enter anything but numbers. When they type any letter or sign I want nothing to show in the textfield. How do I do this?
 
Wirianto Djunaidi
Ranch Hand
Posts: 210
Ruby Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are using Swing, you can change the default Model being used.
Look at the JTextField's javadoc, it shows a snippet of how to do it.
You can explore the How to use TextField which shows you more on how to do it.
And if you are using Java 1.4, you can look into How to use Formatted TextField
[ October 07, 2003: Message edited by: Wirianto Djunaidi ]
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving this to the Swing / JFC / AWT forum...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!