Bonjour,
Voila je remplie une jListe avec des items quand j'essai de récupéré l'index de l'item sélectionné il me renvoi a chaque fois -1 c'est comme si aucun item na été sélectionné voici mon code
Remplissage la jListe :
try {
connec = getConnec();
Statement reqCDS = connec.createStatement();
ResultSet ResultCDS = reqCDS.executeQuery(
"SELECT * FROM items ");
while(ResultCDS.next()) {
dataLIST.add(ResultCDS.getString("produit"));
IDEXLIST.add(ResultCDS.getString("id"));
}
JList jList1 = new JList(dataLIST);
jList1.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
jList1.setVisibleRowCount(-1);
jScrollPane1.getViewport().add(jList1);
jPanel7.add(jScrollPane1);
ResultCDS.close();
}
catch(Throwable exception)
{
System.out.println(exception) ;
}
Sur un clique d'un Bouton j'essai de récupéré l'index du item sélectionné :
String num = (String) IDEXLIST.get(jList1.getSelectedIndex());
j'ai essyé avec :
int num = jList1.getSelectedIndex();
méme probléme!
c'est quoi le probléme SVP
