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

前端 未结 19 2301
陌清茗
陌清茗 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 04:15

    I think it is the best solution:

    JTextField textField = new JFormattedTextField(new MaskFormatter("###")); //
    

提交回复
热议问题