title: A JFormattedTextField to accept a currency format without decimals
body: <p>How do I code a <code>JFormattedTextField</code> to accept a currency format without decimals?</p>
  
  <p>I have tried looking for my answer everywhere. Here, Oracle, Google, and Code Ranch to be specific.</p>
  
  <p>My question: How do I code a formatted text field to accept a currency format without decimals. The text field can accept a value anywhere from $5 to $10,000,000. I would like it to include the "," when need. This field will not be used for mathematical expressions so there is no need to convert it from a string.</p>
  
  <p>Here is the code that I am trying to use. This format is not allowing me to enter any digits at all in the formatted text field.</p>
  
  <p><strong>buildInfo method</strong></p>
  
  <pre><code>//The buildInfo method will build the info panel
  private void buildInfo()
  {
      info = new JPanel();
      GridLayout gl = new GridLayout (3,1);
      info.setLayout (gl);
  
      //Create panel, label, and text area for pledgers name
      p1 = new JPanel();
      p1.setLayout(new FlowLayout(FlowLayout.LEFT));
      label1 = new JLabel ("Pledger's Name:  ");
      p1.add (label1);
      text1 = new JTextField (20);
      p1.add (text1);
  
      //Create panel, label, and text area for pledge amount
      p2 = new JPanel();
      p2.setLayout(new FlowLayout(FlowLayout.LEFT));
      label2 = new JLabel ("Pledged Amount: ");
      p2.add (label2);
      NumberFormat amount = NumberFormat.getCurrencyInstance(Locale.US);
      amount.setMaximumFractionDigits(0);
      NumberFormatter pAmount = new NumberFormatter(amount);
      pAmount.setMinimum(5.0);
      pAmount.setMaximum(10000000.0);
      pAmount.setAllowsInvalid(false);
      text2 = new JFormattedTextField (pAmount);
      text2.setColumns(12);
      p2.add (text2);
  
      //Create panel, label, and text area for charity being pledged
      p3 = new JPanel();
      p3.setLayout(new FlowLayout(FlowLayout.LEFT));
      label3 = new JLabel ("Charity Pledged To:");
      p3.add (label3);
      text3 = new JTextField (20);
      p3.add (text3);
  
      //Add panels to main panel
      add(p1);
      add(p2);
      add(p3);
  }
  </code></pre>