JTextField - liming to an int in a given range?
843804Jul 18 2005 — edited Aug 8 2007Okay, so formatting a JTextField to be an integer is easy:
myTextField = new JFormattedTextField( NumberFormat.getIntegerInstance() );
Apparently I could even format it to be a given number of digits. But I want more... I want to limit the range of numbers to be between 1 and 101. Any values greater than 101 would be changed to 101, and anything less than 1 would be changed to 1.
I tried adding a DocumentListener, but apparently I can't change the text field's value from within the listener, so that's of no help. Any ideas? I'm fairly new to swing. Thanks in advance!
-Vern