コード例 #1
0
  private void importButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_importButtonActionPerformed
    // get selected items from list and try to start import ..
    List<VCard> selectedContacts = new ArrayList<VCard>();
    DefaultTableModel tableModel = (DefaultTableModel) importContactsTable.getModel();
    if (tableModel.getRowCount() == 0) {
      JOptionPane.showMessageDialog(
          this,
          bundle.getString("list.of.contacts.is.empty"),
          bundle.getString("error"),
          JOptionPane.ERROR_MESSAGE);
    } else {
      int[] sel = importContactsTable.getSelectedRows();
      for (int i = 0; i < sel.length; i++) {
        VCard v = (VCard) tableModel.getValueAt(sel[i], 0);
        selectedContacts.add(v);
      }

      if (selectedContacts.size() == 0) {
        JOptionPane.showMessageDialog(
            this,
            bundle.getString("no.contacts.selected"),
            bundle.getString("error"),
            JOptionPane.ERROR_MESSAGE);
      } else {
        // start import of selected contacts
        client.importContacts(
            selectedContacts.toArray(new VCard[selectedContacts.size()]), isVCFVerified);
        this.dispose();
      }
      for (VCard vc : selectedContacts) {
        System.out.println(vc.getStructuredName().getFamily());
      }
    }
  } // GEN-LAST:event_importButtonActionPerformed
コード例 #2
0
    @Override
    public Component getTableCellRendererComponent(
        JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

      if (value instanceof VCard) {
        VCard vc = (VCard) value;
        StructuredName sn = vc.getStructuredName();
        String name =
            sn.getGiven() + " " + sn.getFamily() + " (" + vc.getEmails().get(0).getValue() + ")";
        return super.getTableCellRendererComponent(table, name, isSelected, hasFocus, row, column);
      } else {
        return super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
      }
    }