i have a JTextField that should input only positive integer numbers. So the user shouldn't be allowed to type in anything other than digit chars '0'-'9'. How can i do that ?
1. adding an InputVerifier only restricts the focus (when the text is incorrect). the user can still press buttons or change the tabs of a tabbedpane, leaving an inccorect input in my textfield. so InputVerifier is nice, but not enough for me.
2. i can check the text of the field in a CaretListener, but i cannot change it (with tf.setText(..)) because I get an "attempt to mutate in notifier" exception
3. a KeyListener was my first thought. I can set the text of the tf inside it, but the listener is notified before the text is changed by the keypress (and i can't just remove the event if i don't like it)
hope this makes, sense. any ideeas ? anyone ?