la JList est composée de LigneResultat :
class LigneResultat
{
public String nom_fichier;
public int nb_sources;
public String hash_code;
public LigneResultat(String _nom_fichier, int _nb_sources, String _hash_code)
{
nom_fichier = _nom_fichier;
nb_sources = _nb_sources;
hash_code = _hash_code;
}// LigneResultat
public String toString()
{
return (nom_fichier+"\t\t"+nb_sources);
}
}// LigneResultat
declaration de ma JList :
private DefaultListModel listeModel = new DefaultListModel();
private JList listeResultats = new JList(listeModel);
fenêtre dans laquelle se trouve la JList :
public void fenetreRecherche() throws IOException
{
JFrame fenRech = new JFrame("Rechercher");
fenRech.setSize(350,500);
Container pane = fenRech.getContentPane();
motif = new JTextField("",10);
JPanel panel_rech = new JPanel();
panel_rech.add(etiq_rech);
panel_rech.add(motif);
panel_rech.add(bouton_rechercher);
JPanel panel_resultat = new JPanel();
panel_resultat.add(etiq_nb_resultats);
panel_resultat.add(bouton_telecharger);
pane.add(panel_rech,BorderLayout.NORTH);
pane.add(listeResultats,BorderLayout.CENTER);
pane.add(panel_resultat,BorderLayout.SOUTH);
bouton_rechercher.addActionListener(this);
bouton_telecharger.addActionListener(this);
fenRech.setContentPane(pane);
fenRech.setVisible(true);
}// fenetreConfig
remplissage de la JList :
for(int i=0; i<nb_resultats; i++)
{
String nom_fichier = infos.readLine();
int nb_sources = Integer.parseInt(infos.readLine());
String hash_code = infos.readLine();
LigneResultat resultat = new LigneResultat(nom_fichier, nb_sources, hash_code);
resultats.add(resultat); // resultats est un Vector
}
listeResultats.setListData(resultats);
voila le code
merci