• Post Reply Bookmark Topic Watch Topic
  • New Topic

setting limited number of characters for a text field

 
srijan sharma
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am using a JFormattedTextfield and setting a Format with the constructor.
my problem is i want to limit the charcters in my field too.I can limit the characters using JTexfield when i dunno use a JFormattedTextfield .I would like to get help that how should i limit number of charcters in a JFormattedTextfield.
regards
srijan
 
Tim Troy
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand you, I think this will help. This mask will allow up to 10 characters in the field. Looking at the Javadoc will give you more options.

To really get fancy, try this link.
RegexPatternFormatter from O'Reilly Swing Book
 
srijan sharma
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply but the problem is i cannot use both maskformatter and a formatter on text field together.I mean when i make a textfield for decimal numbers it i need to use decimal format from numberformat which i need to set precision or other properties.So if i use decimal format with JFormattedtextfield then i cannot use a mask formatter as if set it using setFormatterfactory it does not show the desired effect as two things dunno work together.hope i made myself clear
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!