Only allowing numbers and a symbol (-) to be typed into a JTextField

后端 未结 3 1182
天涯浪人
天涯浪人 2020-11-29 11:39

I\'m trying to create a math quiz and I only want the user to be able to enter numbers whether they\'re negative or positive. Is there any way to do so? I\'ve thought of u

3条回答
  •  隐瞒了意图╮
    2020-11-29 12:33

    Alternatively, consider Validating Input using an InputVerifier. A Formatted Text Field may also be suitable.

提交回复
热议问题