title: Java SE7 getpercentinstance
body: <p>I have a program that uses an actionPerformed listener on a JFormattedTextField that is formatted using the NumberFormat.getPercentInstance.  It is set up as follows:</p>
  
  <pre><code>    percentFormat = NumberFormat.getPercentInstance();
      txtRPI = new JFormattedTextField(percentFormat);
      percentFormat.setMinimumFractionDigits(1);
      percentFormat.setMaximumIntegerDigits(2);
      GridBagConstraints gbc_txtRPI = new GridBagConstraints();
      gbc_txtRPI.insets = new Insets(0, 0, 5, 5);
      gbc_txtRPI.gridx = 3;
      gbc_txtRPI.gridy = 2;
      gbc_txtRPI.anchor = GridBagConstraints.FIRST_LINE_START;
      txtRPI.setValue(objParams.getRPI());
      panTop.add(txtRPI, gbc_txtRPI);
      txtRPI.setColumns(10);
      txtRPI.addActionListener(new ActionListener () {
          public void actionPerformed(ActionEvent e) {
              objParams.setRPI((double)txtRPI.getValue());
          }
      });
  </code></pre>
  
  <p>This worked fine until I added the following code on a different JPanel with a table:</p>
  
  <pre><code>public class MyPercentRender extends DefaultTableCellRenderer {
  
  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  private static NumberFormat formatter = NumberFormat.getPercentInstance();
  
  public Component getTableCellRendererComponent(
      JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
      // First format the cell value as required
      formatter.setMinimumFractionDigits(1);
      formatter.setMaximumFractionDigits(2);
      formatter.setMaximumIntegerDigits(2);
      value = formatter.format((Number)value);
  
      // And pass it on to parent class
  
      return super.getTableCellRendererComponent(
      table, value, isSelected, hasFocus, row, column );
      }
  </code></pre>
  
  <p>}</p>
  
  <p>Once this had been added the first field's actionListener stopped being fired and thus I could not save the value.</p>
  
  <p>Has anyone seen this behaviour before and knows what is going on?</p>
  
  <hr>
  
  <p>Thanks for the reply.  I have taken static out.  As far as being part of the event dispatch thread, it is.</p>
  
  <p>I have tried a few more things and it seems that the percentinstance is a red herring.  Even if I take this out the actionlistener is not being fired.  I have checked the object after creation to and the listener is registered along with one other of
  <code>Class&lt;T&gt;</code> .</p>
  
  <p>I have used this code</p>
  
  <pre><code>    txtRPI = new JFormattedTextField();
      GridBagConstraints gbc_txtRPI = new GridBagConstraints();
      gbc_txtRPI.insets = new Insets(0, 0, 5, 5);
      gbc_txtRPI.gridx = 3;
      gbc_txtRPI.gridy = 2;
      gbc_txtRPI.anchor = GridBagConstraints.FIRST_LINE_START;
      txtRPI.setValue(objParams.getRPI());
      txtRPI.setColumns(10);
      txtRPI.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent e) {
              objParams.setRPI((double)txtRPI.getValue());
          }
      });
      panTop.add(txtRPI, gbc_txtRPI);
      this.add(panTop, BorderLayout.PAGE_START);
  </code></pre>
  
  <p>But still the same result.  All my other actionListeners (on buttons and ComboBox) work.  Is there something about Formatted Text?</p>