Is there any way to accept only numeric values in a JTextField?

前端 未结 19 1889
陌清茗
陌清茗 2020-11-22 03:10

Is there any way to accept only numeric values in a JTextField? Is there any special method for this?

19条回答
  •  不思量自难忘°
    2020-11-22 03:58

    This question was cited as an 'exact duplicate' of another question that has since been closed. The answers to this question were so poor that I was inspired to help out anybody that might find it later, by linking to a much better answer for this use case.

    It is an answer to the closed question & can be summed up as..

    Use a JSpinner instead.

提交回复
热议问题