Originally posted by Shawn Rieger:
I've read the sun tutorials on JFormattedTextField but i just can't get it. All I want is a text field that only allows positive integer, and no limit on length. Can someone help me out and just just tell me to look at sun's tutorial.. cause thats not helping me, just making me more confused.
I agree that JFormattedText field isn't documented very well. I recommend the chapter in the 2nd edition of O'Reilly's "Java Swing" book. (disclaimer: I am the author.)
Anyway, it looks like you want to be doing something like this:
<code>
NumberFormatter nf = new NumberFormatter(); // in javax.swing.text
nf.setMinimum(new Long(1));
nf.setAllowsInvalid(false);
JFormattedTextField ftf = new JFormattedTextField(nf);
</code>