Question: I'm writing a simple loan calculator with gui using swing. I used DecimalFormat to make sure I capture the input in my specified format ####.## for my JFormattedTextField .

```
public static void main(String[] args) {
    JFormattedTextField loanAmountField = new JFormattedTextField(new DecimalFormat("####.##"));
    JFormattedTextField interestRateField = new JFormattedTextField(new DecimalFormat("####.##"));
    JFormattedTextField yearField = new JFormattedTextField(new DecimalFormat("####.##"));
    JFormattedTextField monthlyPaymentField = new JFormattedTextField(new DecimalFormat("####.##"));
}

```

When the user press my "calculate" button, it calculates and displays the monthlyPaymentField.

To test if my program will even display it correctly, I tried assigning monthlyPaymentField a value of 12.22, but I'm getting an error that says monthlyPaymentField should be declared as a double.

```
class CalculateListener implements ActionListener {
public CalculateListener (JFormattedTextField loanAmountField, JFormattedTextField     monthlyPaymentField, JFormattedTextField interestRateField, JFormattedTextField yearField, int monthlyTest)
{
  this.interestRateField = interestRateField;   
  this.yearField = yearField;
  this.loanAmountField = loanAmountField;
  this.monthlyPaymentField = monthlyPaymentField;
  this.monthlyTest = monthlyTest;
}

public void actionPerformed(ActionEvent event){

   monthlyPaymentField = 12.22;

    }

}

```

**How do I go about this so that I can still use my JFormattedTextField with DecimalFormat but can still display a Float on my monthlyPaymentField?**

Answer: 
You can use the [`setValue`](http://www.open.collab.net/nonav/community/cif_cee/pt/javadoc/tracker-ws/com/collabnet/tracker/ws/SetValue.html) method for this;

```
monthlyPaymentField.setValue(new Double(12.22)); 

```
Use [setValue](http://docs.oracle.com/javase/6/docs/api/javax/swing/JFormattedTextField.html#setValue%28java.lang.Object%29), ie: 

```
monthlyPaymentField.setValue(new Double(12.22));

```

[How to Use Formatted Text Fields](http://docs.oracle.com/javase/tutorial/uiswing/components/formattedtextfield.html) tutorial has a good example with doubles.