2
I have the following method for adding objects to a JComboBox
:
public void PopulaCategoria() throws SQLException{
for(Categoria categoria : caDAO.getCategorias()){
comboCategoria.addItem(categoria);
}
}
But he made a mistake in comboCategoria.addItem(categoria);
saying that Categoria
cannot be converted into String
, but I’ve already put the method toString()
inside my model Categoria
:
@Override
public String toString(){
return this.nomCategoria;
}
He shouldn’t add the objects inside the JComboBox
and show only the name?
It’s Swing or Javafx?
– Jéf Bueno
I’m using Swing
– Eduardo Balestrin