I have a JComboBox and a class named clsPais:
public class clsPais {
private long id = 0;
private String nombre = "";
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
@Override
public String toString() {
return nombre;
}
}
In my JFrame code I put:
clsPais p1 = new clsPais();
p1.setId(1);
p1.setNombre("ARGENTINA");
clsPais p2 = new clsPais();
p2.setId(2);
p2.setNombre("BRASIL");
cmbPaises.removeAllItems();
cmbPaises.addItem(p1);
Here, i have an error, telling me "incompatible types: clsPais canot be converted to string". The addItem from my JComboBox only accept String parameter. What can I do?
Thank you