Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

rendering JPanels in a JList

Status
Not open for further replies.

kmcculler

Programmer
Jul 5, 2000
81
0
0
US
Hi all,
I'm trying to display some JPanels (with various controls and such) on a JList.. each cell of the list would be its own panel providing info on diffrent database info I pass to it.
Can anyone help me to do this?? when I just added the panel to the listmodel I got the toString of the panel displayed, when I tried adding a cell renderer that extended JPanel it just didn't show up. Although when I looked at the list it was like it had an item selected but nothing was visible except a gray bar...
Let me know if you can help.
Thanks Kris McCuller
Programmer Portiva Corp.
kmcculler@portiva.com
 
Hi kmcculler,
i guess you've already reviewed the Java reference on this topic!?

I've received strange results when using the same component multiple times in the JList. To be precise i did the same thing with a JTree, but this shouldn't be any difference.

Always call setOpaque(true) for the component put in the JList.

Unfortunately i haven't got my old source right here, but this should be the major points.

Christoph
 
Yes, I have read the Java refrence before. I've even used it with diffrent components, namely a checkslist I created where the cellrenderer extended JCheckbox. My problem is that I just can't seem to get it to work with JPanel. Any help is still appreciated. Kris McCuller
Programmer Portiva Corp.
kmcculler@portiva.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top