It isn't even easy to get a JLabel from a JPanel. But why should it be easy? JPanel wasn't designed as a container for a JLabel, so there is little reason for JPanel to provide an obvious method to get a JLabel out of it. There are unobvious methods, though, but I recommend doing what you did.
Although really I recommend reviewing why you decided you needed the JPanel. I don't see a need for it, but perhaps you found that something didn't come out right if you just just used a JLabel by itself?
Actually you don't even need to use a JLabel, since your cell renderer already is (or can be) a JLabel. All your renderer code needs to do is to set the colours of the renderer appropriately.
If you can post a working code; then we can help.
posted 9 years ago
yeah i did think about ditching the panels and just labeling up the listed items but i found it was cleaner to package everything up in its individual panel then add all the panels to the list then access those panles from a master array and sub array...
it all works fine it was a question really to find out if it was possible to access these labels from within panels which i know now you cant so in future projects i will know to think of another way to display the items...
thanks for you guys help i have learnt so much here already as there are people that do reply to post
hopefully in time maybe i can help people out once i get enough practise in....
I can't take it! You are too smart for me! Here is the tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop