Limiting Textfields in Java

后端 未结 4 591
暗喜
暗喜 2021-01-20 00:42

Is there a way to limit a textfield to only allow numbers 0-100, thereby excluding letters, symbols and such as well? I have found a way, but it is way more complicated than

4条回答
  •  臣服心动
    2021-01-20 01:20

    I'd suggest you should go with a JSpinner in this case. Text fields are pretty complicated to work with in Swing since even the most basic single-line ones have a full-blown Document class behind them.

提交回复
热议问题