NumberFormat text field without commas

后端 未结 1 1740
醉酒成梦
醉酒成梦 2021-01-02 11:09

I have a JFormattedTextField which I want to accept numbers in the 5 digit range. The following code works correctly:

myNumberBox = new JFormattedTextField(N         


        
相关标签:
1条回答
  • 2021-01-02 11:45

    You have to disable the grouping in your NumberFormat object like this:

    NumberFormat format = NumberFormat.getIntegerInstance();
    format.setGroupingUsed(false);
    myNumberBox = new JFormattedTextField(format);
    

    See: NumberFormat.setGroupingUsed

    0 讨论(0)
提交回复
热议问题