Get the selected item from a ComboBoxProduct in JavaFX?

0

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?

    
asked by Nelson Castiblanco 20.06.2018 в 21:57
source

0 answers