This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
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.
Dave Robbins
Ranch Hand
Joined: Sep 16, 2003
Posts: 131
posted
0
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
Dave
Dave Robbins
Ranch Hand
Joined: Sep 16, 2003
Posts: 131
posted
0
hmm, Paul I think you're onto something investigating further thanks
Dave
Dave Robbins
Ranch Hand
Joined: Sep 16, 2003
Posts: 131
posted
0
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
Thanks Dave
Craig Wood
Ranch Hand
Joined: Jan 14, 2004
Posts: 1535
posted
0
Dave Robbins
Ranch Hand
Joined: Sep 16, 2003
Posts: 131
posted
0
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