How can I implement a JList with varible row height? Can someone provide me a complete example code?
Thanks.
-Dan
[ July 08, 2005: Message edited by: S Dan ]
if you mean variable between lists, look up setFixedCellHeight()
if you mean variable between rows of a list, look up DefaultListCellRenderer where you override getListCellRendererComponent() to set the preferredSize of the label, depending on the criteria of the row
Doesn't work. I already tested that before posting the message. I've overridden getListCellRendererComponent. I'm trying to change the height of a particular row when the cell is selected. So I'm trying to do this inside the getListCellRendererComponent method.. if(isCellSelected){ this.setPreferredSize(new Dimension((int)this.getSize().getWidth(),50)); this.validate(); }
No effect whatsover. Using setSize instead of setPreferredSize doesn't help either.
works OK if you reset the renderer in ListSelectionListener's valueChanged() and in getListCellRendererComponent if(list.getSelectedIndex() == index) lbl.setPreferredSize(new Dimension(100,75)); else lbl.setPreferredSize(new Dimension(100,20));