Hi, I wnat to create a JTextField that accepts 0-9 only. I tried the following code,
it worked, but jTextField.selectAll() and jTextField.setText("String") stopped working. I can't seem to figure out the reason. Can someone please help? Thanks a lot!
Jason O' Regan
Joined: May 26, 2003
You should implement a Document that only accepts numeric values, by subclassing the javax.swing.text.PlainDocument class and overriding the insertString method there. Then add this Document to the JTextField using the setDocument method.
--------------------------<br />Jason O'Regan<br />SCJP, SCJD, SCWCD, SCBCD, SCEA.<p>Artificial intelligence is no match for natural stupidity.