Exemplo n.º 1
0
 // Delete a contact given by contactId (between 0 and max contacts). Returns
 // 1 if success otherwish returns 0.
 static int deleteContact(int contactId) {
   // #ifdef api.pim
   if (contactId >= 0 && contactId < s_contacts.length) {
     try {
       ContactList list = (ContactList) s_contacts[contactId].m_contact.getPIMList();
       list.removeContact((s_contacts[contactId].m_contact));
       s_contacts[contactId] = null;
       s_nbContacts--;
       for (int i = contactId; i < s_nbContacts; i++) {
         s_contacts[i] = s_contacts[i + 1];
       }
       return 1;
     } catch (Exception e) {
       Logger.println("Exception while deleting contact: " + e);
     }
   }
   // #endif
   return 0;
 }
Exemplo n.º 2
0
 public void actionPerformed(ActionEvent e) {
   if (to == e.getSource()) {
     toSendWindow();
     // Display list for user selection
     // puts user selection into JTextField to
   } else if (addContacts == e.getSource()) {
     addContactWindow();
     // Display prompt for information for new contact
     // Uses information to add to ContactList collection
     //
   } else if (removeContacts == e.getSource()) {
     removeContactWindow();
     // Display prompt for removing contacts
     // Uses information to remove from ContactList collection
   } else if (editContacts == e.getSource()) {
     editContactWindow();
     // UI for editing contacts
   } else if (save == e.getSource()) {
     cList.addContact(
         new Contact(
             newContactFields[0].getText(),
             newContactFields[1].getText(),
             newContactFields[2].getText()));
     JOptionPane.showMessageDialog(
         null, "The contact has been added.", "Success!", JOptionPane.INFORMATION_MESSAGE);
     addWindow.dispose();
   } else if (deleteContact == e.getSource()) {
     ContactList cDeleted = contactList.getContacts();
     for (int i = 0; i < cDeleted.getLength(); i++) {
       cList.removeContact(cDeleted.getContact(i));
       /*
       PLACEHOLDER FOR REPAINT
       */
     }
     removeWindow.dispose();
   } else if (addSendContacts == e.getSource()) {
     toText.setText(toText.getText() + contactList.getEmails());
     toWindow.dispose();
   }
 }