• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextField that accept only Capital letter.

 
Sanju Thomas
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a typical requirement. I need to create a TextFiled that accept only capital letters, that does not mean the user must enter it in capital letter. The TextField must accept small letter too but must convert it in the time of insertion itself. I can covert it into capital letter in the lostFocus, but it will create some other problems to my code.. so I want to know how to create a TextField that convert the input in to caps in the time of insertion itself. ( I have seen this in many sites) I think you guys must have understood the requirement. I am sure many of you must have done it already, can you guys please help me to crack this.. ? waiting for your response..
 
Qunfeng Wang
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's DocumentFilter!
Write your own DocumentFilter, override insert() and replace method(). You can refer to API and Java tutorial for more details.
Good luck!
 
Mike Rane
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Click here. The example is near the top.
 
Sanju Thomas
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanx Guys..
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!