Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

Jlist - ListModel and CellRenderer

Thread view: 
Martin Mücke - 17 Oct 2006 21:42 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.