I have a combo box and I'm adding an object called haplotype and overriding the toString method to display the name of the object like this:
cmb.addItem(new tables.Haplotype ( rs.getInt("HTY_HAPLOTYPE_ID"),rs.getString("HTY_TEXT")));
It gets the id of the haplotype and the name from a database and adds it to a combo box.
The problem I'm having is that when I try to update the object to the database I get the following error message:
from this line of code
tables.Haplotype h1 = (tables.Haplotype) HLA_Haplotype1Cmb.getSelectedItem();
Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.String cannot be cast to tables.Haplotype
This is making me totally confused, since I'm sure I'm adding the Haplotype object to the combo box. Is it possible that it's adding a string in some cases?