displaying an object in the list

I have a custom Object with many parameters:

Coffee c = new Coffee();

Coffee has parameters such as brand, instant, price, etc.

When I add it to the list with model.add(0, c), on the list it displays something weird instead of displaying the set parameters. What's the trick to get it to display something like this when added to the list:

Coffee instant, Nescafe, etc...

The list is a JList and I am using a DefaultListModel.

Thanks for any help in advance!!

[503 byte] By [olga1985a] at [2007-11-26 16:41:40]
# 1
Override the toString method.
zadoka at 2007-7-8 23:08:42 > top of Java-index,Desktop,Core GUI APIs...
# 2
Or use a custom cell renderer, if you want to have more control: http://java.sun.com/docs/books/tutorial/uiswing/components/list.html#renderer
Rodney_McKaya at 2007-7-8 23:08:42 > top of Java-index,Desktop,Core GUI APIs...
# 3
Thanks guys! I overrided the toString() and now it displays it properly, but I can't edit it. Is there a way to convert the String back into an object?
olga1985a at 2007-7-8 23:08:42 > top of Java-index,Desktop,Core GUI APIs...
# 4
Write a method that gets the string, parse it, and update your object.
Rodney_McKaya at 2007-7-8 23:08:42 > top of Java-index,Desktop,Core GUI APIs...
# 5
I just tried creating a renderer and it worked!!! :) Thanks again!
olga1985a at 2007-7-8 23:08:42 > top of Java-index,Desktop,Core GUI APIs...