title: JavaFX focusedProperty().addListener refactor code
body: <p>I have text fields on a form where I have I perform an action when the field is not in focus. I have a separate listener code for each field and was wondering how I can merge this code so that there is one listener code for all the fields as I have duplication of code and the only thing is different is the textfield name.</p>
  
  <pre><code>@Override
      public void initialize(URL url, ResourceBundle rb) {
  
  
          callPremium.focusedProperty().addListener(new ChangeListener&lt;Boolean&gt;()
          {
              @Override
              public void changed(ObservableValue&lt;? extends Boolean&gt; arg0, Boolean oldPropertyValue, Boolean newPropertyValue)
              {
                  if (newPropertyValue == false &amp;&amp; !callPremium.getText().trim().isEmpty())
                  {
                      SIMTradeCalculatorModel model = new SIMTradeCalculatorModel(numShares, purchasePrice, brokerage, callStrikePrice, putStrikePrice, putPremium, callPremium);
                      model.validateDecimal(callPremium, errorDisplay, performCalculationButton);
                      model.checkAllFields(performCalculationButton);
                  }
                  else {
                      callPremium.setText(callPremium.getText().trim());
                  }
              }
          });
  
          putPremium.focusedProperty().addListener(new ChangeListener&lt;Boolean&gt;()
          {
              @Override
              public void changed(ObservableValue&lt;? extends Boolean&gt; arg0, Boolean oldPropertyValue, Boolean newPropertyValue)
              {
                  if (newPropertyValue == false &amp;&amp; !putPremium.getText().trim().isEmpty())
                  {
                      SIMTradeCalculatorModel model = new SIMTradeCalculatorModel(numShares, purchasePrice, brokerage, callStrikePrice, putStrikePrice, putPremium, callPremium);
                      model.validateDecimal(putPremium, errorDisplay, performCalculationButton);
                      model.checkAllFields(performCalculationButton);
                  }
                  else {
                      putPremium.setText(putPremium.getText().trim());
                  }
              }
          });
  }
  </code></pre>