Java JSpinner Prevent Letter Insertion

Posted by asmo on Stack Overflow See other posts from Stack Overflow or by asmo
Published on 2010-06-09T14:49:01Z Indexed on 2010/06/09 14:52 UTC
Read the original article Hit count: 245

Filed under:
|
|
|
|

A JSpinner is used to store a number in my application (with a SpinnerNumberModel).

As expected, the spinner doesn't allow invalid characters (letters, symbols, etc.) to be stored. However, those characters do appear in the spinner component when I type them in. As soon as I switch the focus to another component, they disappear.

Is there a way to prevent invalid characters from appearing in the spinner?

© Stack Overflow or respective owner

Related posts about java

Related posts about prevent