OK, I'm stumped trying to use custom icons for the nodes in a JTree I made my own TreeCellRenderer
and I used it like this when I create and populate my tree
I run the code in a debugger and everything seems to work right but on the GUI there are just default icons I even made a JLabel and set the icon to display in it and that works so the image is getting loaded I'm guessing there's something wrong with the order in which I'm doing things, like when stuff get's created but it looks right to me I can put a breakpoint in MyTreeCellRenderer and see the code jump in there
Do your tree nodes REALLY contain DefaultMutableTreeNode objects as their user objects? If not, then your renderer would be throwing a class-cast exception where you cast the value to that type. And if you do, that's a really strange design.
my nodes are objects that extend DefaultMutableTreeNodes they're extended such that they contain info about how to lookup stuff for that node in a database the functions I'm calling, set*Icon haven't been overloaded so I think what I'm doing is ok, but I could be wrong I have been before
doh what's behind door number 3 it would be a "really strange design" :roll: I shouldn't extend DefaultMutableTree node like I'm doing I should use setUserObject to include the additional info my bad
ok, found the problem the folks who think IDE's are terrible and you should write all your code with a text editor are gonna laugh after I built my nice little tree with all the custom icons, the auto-generated code that netbeans had written came along behind me and re-initialized my tree interestingly, now that I've found the problem I see that creating my own treenodes that extend a DefaultMutableTreeNode isn't a problem I didn't think it should be but now that I see how I can use setUserObject to do the same thing I see that it's kinda a waste of time
Thanks for all the help Dave
You ought to ventilate your mind and let the cobwebs out of it. Use this cup to catch the tiny ads:
New web page for Paul's Rocket Mass Heaters movies