• Post Reply Bookmark Topic Watch Topic
  • New Topic

add Format after component creation  RSS feed

 
Tim McGuire
Ranch Hand
Posts: 820
IntelliJ IDE Tomcat Server VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I have an existing JFormattedTextField, how would I apply a new Format to it?

if I am creating a new one, I can say:
txtZipCode = new JFormattedTextField(new MaskFormatter("#####"));

but if txtZipCode already exists,

is there no method to set the format?
txtZipCode.setFormat(new MaskFormatter("#####"));
 
Aaron Roberts
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you looked at the API where it talks about getting/setting the AbstractFormatter? It appears your answer may lie there.

http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JFormattedTextField.html

HTH,
Aaron R>
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!