Example #1
0
 /**
  * Refreshes the text fields with current data
  *
  * @param contact Current contact
  */
 private void refresh(IEmailKontakt contact) {
   ek = contact;
   if (ek == null) {
     textField.setText("");
     textField_1.setText("");
     textField_2.setText("");
     textField_3.setText("");
     ek = ekd.create();
   } else {
     textField.setText(ek.getVorname());
     textField_1.setText(ek.getNachname());
     textField_2.setText(ek.getEmail());
     textField_3.setText(ek.getId() + "");
   }
 }
Example #2
0
 /** Saves a contact */
 private void saveContact() {
   Pattern p =
       Pattern.compile(
           "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$");
   Matcher m = p.matcher(textField_2.getText().trim());
   if (ek != null
       && !(textField.getText().isEmpty())
       && !(textField_1.getText().isEmpty())
       && !(textField_2.getText().isEmpty())
       && m.matches()) {
     int response =
         JOptionPane.showConfirmDialog(
             this, "M\u00F6chten Sie die Daten wirklich \u00FCbernehmen?");
     if (response == JOptionPane.YES_OPTION) {
       ek.setVorname(textField.getText().trim());
       ek.setNachname(textField_1.getText().trim());
       ek.setEmail(textField_2.getText().trim());
       ekd.save(ek);
     }
   } else {
     JOptionPane.showMessageDialog(null, "Die Felder wurden nicht korrekt ausgef\u00FCllt!");
   }
 }