I’m trying to create a custom editor on a component I’ve created that will pull a list of global resources and present them as a key/value pair dropdown. I tried using a JComboBox with a collection of custom classes like the Stack Overlfow answer here.
When I look at my component in the designer, I’m left with text to the classpath of my inner class. Are there any examples of how to do this?
You need to override the combobox’s cell renderer (so that it examines the objects, and returns text in a useful way; specifically you need to override getListCellRendererComponent
) or, if you just want to keep using the default cell renderer, then override toString
on your objects.
All I had to do was actually read the StackOverflow Post
In addition I had to override the getValue and setValue methods of ConfiguratorEditorSupport to set my custom class, but return an integer because it was still expecting my custom class for some reason. It feels like a janky workaround but it’s working I think…
Thanks Paul.
1 Like