I have a JComboBox of type myclass. I use CustomListRender to display one of the attributes of myclass, and it works fine.
Then I set myCombobox.setEditable(true). JComboBox becomes editable, but by default text is set to somthing like this in combobox:
com.mypackagename.myclass
Can anyone tell me how to solve this problem?
Thanks in advance.
As discussed in How to Use Combo Boxes: Providing a Custom Renderer,
Unless overridden, you’re probably seeing the
toString()implementation inherited fromObject. At a minimum, you’ll need to overrideMyClass#toString()orupdate your renderersupply a custom editor accordingly; there’s a related example here. Most would prefer the latter; your sscce showing your custom renderer would make it easier to suggest alternatives.