I have created an instance of ComboBox<Producto>
with items from a ObservableList<Producto>
that I have filled from the database with instances of class Producto
.
To obtain the selected item, use the method getValue()
or Method getSelectectionModel().getSelectedItem()
of the ComboBox, and this returns the selected item of type Producto
.
But when the ComboBox is comboBox.setEditable(true)
the 2 previous methods do not return an object of type Producto
, only return a String, then when doing this: Producto p = comboBox.getValue();
throws me this as error : String can not cast to Producto
.... When the ComboBox is comboBox.setEditable(false)
everything works perfect.
What could it be?