Dynamically changing size of JList items?

Hello!

I'm working on an application which kind of revolves around a JList with a custom ListCellRenderer. Now, it all works rather good as it is, but I want the selected JList item to show more detailed information about the selected value, and thus I need it to be bigger then the not selected items. The thing is that no matter what I do I can't seem to make the JList adopt to the new size of the selected item, which results in only half of the stuff in the selected item being shown.

Is there any way to do this it would be great! (I bet there is some really simple way which I have simply overlooked.)

And, fyi: The component returned by getListCellRendererComponent is a JPanel which consists of three JLabels using a GridLayout. The selected component is generally the same, but with an extra row in the GridLayout.

Any help/suggestions will be greatly appreceated!

Yours, Jiddo.

[930 byte] By [Jiddoa] at [2007-11-26 22:27:12]
# 1
You know that GridLayout forces all rows and columns to be of the same size, right? I have not tried what you are doing. But one of the first things I would try is changing the LayoutManager.
abillconsla at 2007-7-10 11:29:20 > top of Java-index,Java Essentials,Java Programming...
# 2

I have tried with a couple of different layout managers, and none of them (except for this one) seems to offer me the layout I need. Also, I have tried making it return different instances depending on if it is selected or not. The non-selected one has only one row in the layout while the selected has two. Here is a screenshot of how it looks:

http://img211.imageshack.us/img211/2779/jlistes1.jpg

Yours, Jiddo.

Jiddoa at 2007-7-10 11:29:20 > top of Java-index,Java Essentials,Java Programming...
# 3
not sure this is what you're after - changes the selected row's height http://forum.java.sun.com/thread.jspa?threadID=649772
Michael_Dunna at 2007-7-10 11:29:20 > top of Java-index,Java Essentials,Java Programming...
# 4

Thanks a bunch. I'll try it out as soon as I get home. (It looks like it's just what I was looking for :))

Also, when I think about it, perhaps a JTable is what I should use after all. I'll try both solutions and see if any works.

Yours, Jiddo.

Message was edited by:

Jiddo

Jiddoa at 2007-7-10 11:29:20 > top of Java-index,Java Essentials,Java Programming...