how to set mutable cell width and height in a jlist?

Hello,

i wrote a jlist cell renderer object to able to render a jlabel for the unselected items and a wide and high jpanel with images when an item is selected.

The jlist render all items at the same dimension.

How can i change this built-in behavior?

i printed the items preferedsize:

java.awt.Dimension[width=340,height=140]

java.awt.Dimension[width=275,height=75]

java.awt.Dimension[width=275,height=75]

java.awt.Dimension[width=275,height=75]

java.awt.Dimension[width=275,height=75]

java.awt.Dimension[width=275,height=75]

java.awt.Dimension[width=275,height=75]

Message was edited by:

fazekaim

ok, i give for every index pos a fix jpanel object, and it is working.

What i would like is a mouse selection and the selected item/cell should be rendered by a component with different dimension (containing more information). but this doesn't work.

Is it possible, that the JList cashes the cells dimensions?

Message was edited by:

fazekaim

Message was edited by:

fazekaim

[1103 byte] By [fazekaima] at [2007-11-27 8:28:36]
# 1
Not the best idea. The component you are returning is used during the painting sequence, and you're trying to change the cell size. What would you expect to happen? Relayout the entire list while it is being repainted?
kirillga at 2007-7-12 20:18:38 > top of Java-index,Desktop,Core GUI APIs...
# 2

i just want to change a cell for another when i click on it.

there are names in the jlist. after having click on one of them, a description panel could be appears in the list instead of the short name. it' a simple ui effect, i think.

is there any other way than write a custom jlist implementation?

fazekaima at 2007-7-12 20:18:38 > top of Java-index,Desktop,Core GUI APIs...
# 3
http://forum.java.sun.com/thread.jspa?threadID=649772deals with modifying the height of the selected item, so could be similar (in princple)to what you're trying to do
Michael_Dunna at 2007-7-12 20:18:38 > top of Java-index,Desktop,Core GUI APIs...
# 4
Thank You!
fazekaima at 2007-7-12 20:18:38 > top of Java-index,Desktop,Core GUI APIs...