Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Individual cell heights in JList

843804Dec 1 2004 — edited Dec 3 2004
hi!

i'm trying to write a cellrenderer for a JList, which can show different cell heights.
i.e. in unselected mode, i only want to show a name of a person; in selected mode, i want do show the name of the person AND some other details in the same cell (like the "add and remove programs"-dialog of Windows XP when you select a program to uninstall (it shows then some information about usage etc.))
if(!isSelected) {
    /* Not selected */
    setPreferredSize(new Dimension(0,25));
    setBackground(Color.BLUE);
} else {
    /* Selected: */
    setPreferredSize(new Dimension(0,45));
    setBackground(Color.RED);			        
}
i tried this code in the getListCellRendererComponent(...)-method, but the JList only uses the first size (25) ... i tried to set the JList-propertie fixedCellHeight to -1, but no changes....

does anybody know how i can solve my problem?
thx a lot & greetz
swissManu
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 31 2004
Added on Dec 1 2004
18 comments
302 views