Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Prevent spaces from being accepted in a JTextField  RSS feed

 
Roshan Rama
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a JTextField and i don't want it to accept any Spaces or other characters..
How can i go about doing this??
Does anyone have sample code for me??

Thanks
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Roshan,
Welcome to the Ranch.

Check out this example of a numeric text field.http://faq.javaranch.com/java/NumericTextField
That should give you a clue how you can go about achieving your functionality.

As this is more related to Swing, I am moving this thread to the proper forum.
To get the most from the forums, you might want to go through this
http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!