java.lang.String cannot be cast to Item
Bonjour à tous , j'ai un souci que ne comprends pas.
J'ai une JComboBox qui contient 7 éléments.
J'aimerais la balayer pour récupérer les éléments:
Code:
1 2 3 4 5 6 7
| for(int t=0;t<adressePanel.perCatCombo.getItemCount();t++){
int k = ((Item)adressePanel.perCatCombo.getSelectedItem()).getId();
} |
Mais j'ai une exception générée alors que ailleurs dans le programme cela fonctionne:
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 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
package com.vv.tribune;
public class Item
{
private int id;
private String description;
private String value;
public Item(int id, String description)
{
this.id = id;
this.description = description;
this.value = "";
}
public void setValue(String val) {
value = val;
}
public int getId()
{
return id;
}
public String getDescription()
{
return description;
}
public String getValue()
{
return value;
}
public String toString()
{
return description;
} |
merci.