title: set Value to Jformattedtextfield using MaskFormatter in java
body: <p>I have a MaskFormatter and Jformattedtextfield .The code for that is</p>
  
  <pre><code>try {
      mk = new MaskFormatter("**-**-**-**-**-**-**-**-**-**-**-**-**-**-**");
      mk.setPlaceholderCharacter('_');
  } catch(ParseException e) {
      e.printStackTrace();
  }
  
  format1=new JFormattedTextField(mk);
  format1.setBounds(170, 80, 280,25);
  format1.setFont(new Font("serif",Font.PLAIN,13));
  commandpanel.add(format1);
  </code></pre>
  
  <p>I have added maskformatter to jformattedTextfield.On click of a button i am trying to set a value to format1 but nothing is getting displayed in format1 field.</p>
  
  <p>This is the code for setting the value</p>
  
  <pre><code>// value may be 1E0234
  String value=hashmap1.get("Command 1").substring(hashmap1.get("Command 1").lastIndexOf("-")+2, hashmap1.get("Command 1").length());
  
  format1.setValue(value);
  </code></pre>
  
  <p>I also tried with format1.setText(value),in this case it is displaying in the field but without a maskformatter.</p>
  
  <p>How do i display the value along with the mask.</p>