Jformattedtextfield deleting entered data

Asked

Viewed 40 times

2

I have 4 Textfields to put DDD, numbers before the hyphen, numbers after the hyphen and zip.

private JTextField ddd=null;

private JTextField antesh=null;

private JTextField depoish=null;

And a method formatarTextboxes();

try{
            this.ddd = new JFormattedTextField(new MaskFormatter("###"));
            this.antesh = new JFormattedTextField(new MaskFormatter("#####"));
            this.depoish = new JFormattedTextField(new MaskFormatter("####"));
            this.cep = new JFormattedTextField(new MaskFormatter("#####-###"));
        }catch(Exception e){
            System.out.println(e);
        }

However, when I enter for example, 27 in the DDD and tab or field change to add data in the other Textboxes, the content that I entered in the DDD simply disappears, I can’t see error in my code, since it was working properly a couple of days ago when I didn’t even touch the code.

  • 1

    Please add a [mcve] of your code so it is possible to test and see the problem running.

  • 1

    The way it is, once you assign null the variables, the first attempt to assemble this into a code that I can compile and test will give NullPointerException. It is very likely that your problem is in a part of the code that is not the one you posted. Follow the suggestion of colleague @Articuno and post a [mcve].

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.