Salve, siamo a lunedì e con un nuovo quesito.
Ho questo:
codice:
ArrayList<String> strings = new ArrayList();
SearchableListModel listModel = null;
strings = getArrayString();
listModel = new SearchableListModel(strings);
searchList = new javax.swing.JList();
searchList.setModel(listModel);
In particolare, l'ArrayList<String> strings è costituito da stringhe, appunto, tramite il metodo getArrayString().
codice:
public ArrayList<String> getArrayString(){
UserProfile user = Persistence.getCurrentUserProfile();
ContactsManager contactsManager = new ContactsManager(user);
List<Contact> contactList;
String name = "";
String tel = "";
String infoUser = "";
ArrayList<String> cl= new ArrayList<String>();
contactList = contactsManager.loadContacts();
for (Iterator<Contact> it = contactList.iterator(); it.hasNext();) {
Contact c = it.next();
name = c.getName();
tel = c.getTel();
infoUser = name + " " + tel;
cl.add(infoUser);
}
return cl;
}
Per avere un icona accanto a ciascun nome presente nella Jlist, dovrei implementare una classe che implementa ListCellRenderer. All'interno di questa classe, settare ciascuna cell (riga della jlist) data da "icona + stringa" e poi scrivere
codice:
searchList.setsetCellRenderer(new MyCellRenderer());
La cosa che non capisco è come faccio nella classe che implementa ListCellRender a passargli la stringa, intesa come ciascun elemento dell'array di stringhe che riempie il listModel?
Utilizzando appunto un listModel che estende l'interfaccia AbstractListModel, è cmq questo il corretto procedimento?

ps: Spero di aver spiegato bene la situazione, devo dire che il lunedì mattina è proprio duro!