AbstractListModel et Collection
Bonjour,
J'ai un petit soucis je n'arrive pas à récupérer ma collection dans mon AbstractListModel afin d'ajouter ca dans ma Jlist. Voici mes codes :
Main
Code:
1 2 3
|
monAnnuaire.remplir_collection();
List_Contact.setModel(new ListData()); |
Petit détail, j'arrive a afficher ce que possède ma collection, elle est bien implémenté. Pour pouvoir récupérer ma collection je l'ai rendu public :
Code:
1 2
|
public Contact[] MesContacts; |
Et voici la ou je bloque, je n'ai pas d'erreurs mais ca n'affiche rien,
AbstractListModel :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
import javax.swing.AbstractListModel;
class ListData extends AbstractListModel {
ConnectSQL connectSQL = new ConnectSQL();
Annuaire monAnnuaire = new Annuaire();
Contact[] Contacts = monAnnuaire.MesContacts;
String[] tab_contact = new String[Contacts.length];
ListData() {
for (int i = 0; i < tab_contact.length; i++) {
tab_contact[i] = Contacts[i].getPrenom();
System.out.println(tab_contact[i]);
}
}
public int getSize() {
return tab_contact.length;
}
public Object getElementAt(int index) {
return tab_contact[index];
}
} |
Merci de votre aide, bonne journée