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

JTextField input  RSS feed

 
Mike Stead
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is there a way to limit the number of characters that a user can enter into a JTextField. For example... If 3 JtextField exist in a GUI, one for the day, one for the month and one for the year (just for example), the day field should never have more than 2 characters entered.
I guess what I'm trying to ask is, is there a way to stop user input into a text field once the max number of characters are entered?
Thanks
M.S
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at the example in the tutorial (validated textfield). You can modify it a little to get the result you want.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!