title: JComboBox Selection Change
body: <p>everyone i am quite new to Java GUI, i am  having an issue with a JComboBox , where it is firing when i removeAllItems from a combo box to refresh it, this is an issue because i am getting the selected items Details and populating a textboxes with them so as it is firing at that point i am getting a Null Pointer.
  Is there any simple(ish) way to have method on the ComboBox that is called when the selected item is changed not just when the combo box contents is changed?</p>
  <h2>Code</h2>
  <p>comboBox current method</p>
  <pre><code>private void customerComboActionPerformed(java.awt.event.ActionEvent evt) {                                              
      
     setDetails();
      
  } 
  </code></pre>
  <p>Method for setting the Items in the combo Box</p>
  <pre><code>public void setCustomers()
  {
  customerCombo.removeAllItems();
  for (Customer curr : Main.getNewCustomerList().getCustomers())
  {
   
      customerCombo.addItem(curr);
  }
  }
  </code></pre>
  <p>method for setting the details</p>
  <pre><code>public void setDetails()
  {
  Customer selected = (Customer) customerCombo.getSelectedItem();
  forenameText.setText(selected.getForename());
  surnameText.setText(selected.getSurname());
  costperkgText.setText(String.valueOf(selected.getDeliveryCost()));
  line1Text.setText(String.valueOf(selected.getColAddress().getAddressLine1()));
  line2Text.setText(String.valueOf(selected.getColAddress().getAddressLine2()));
  cityText.setText(String.valueOf(selected.getColAddress().getCity()));
  postcodeText.setText(String.valueOf(selected.getColAddress().getPostcode()));
  
  }
  </code></pre>