I was trying to modify the data type of a combo box named cbLicense
in Swing. In this case, I wanna change from String
to CustomerItem
which is a class. I use Swing design, so I selected the combo box, went to Properties/Code/TypeParameters. But the problem is that on the Generated Code
section, there's still a line:
cbLicense.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
This line has an incompatible type error. So how do I fix it? Do I need to add each CustomerItem
object into cbLicense
via Design view? Because the CustomerItem
value is retrieved from the database.
Find the way to customize combo box in Swing