Hi,
I want to create a JList containing a list of objects (containers).
When showing those objects in the list, I want to see a string,
but when working with those Objects of course I need other values,
especially the objects database key as well.
Do I have to implement my own ListModel, or can I do without?
Would you even recomend to use my own CellRenderer, or does a simple
toString() method in my object do?
thanks,
Martin
Thomas Hawtin - 17 Oct 2006 21:53 GMT
> I want to create a JList containing a list of objects (containers).
> When showing those objects in the list, I want to see a string,
[quoted text clipped - 3 lines]
> Would you even recomend to use my own CellRenderer, or does a simple
> toString() method in my object do?
Simply providing a toString on the objects will do. If you can't change
the objects themselves then you can write a simple proxy that holds the
original object, but does its own thing with toString.
For anything more complicated you will need a renderer. I suggest
keeping the renderer as simple as possible, putting most of the logic in
the objects themselves (or proxies).
Tom Hawtin