This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
Hello guys! This is my first post on this forum I am a beginner to java! What i want to do is make a drag and drop from a jtree and a JList. The Jtree contains the all file system and want to drop only drop the filename with path to the JList. I found an example of FileTree which uses a custom TreeNode (FileTreeNode) and a custom TreeCellRenderer (FileTreeCellRenderer) i will post the code:
The problem is it uses a DeafaultMutableTreeNode and i use a custom TreeNode.
Can anybody can help me to make the userObjectMethod() for my custom FileTreeNode? It doesn`t show the filename and path to the JList when i drop it from the jtree it shows something like this Test.FileTreeNode@1f78ef1 where Test is the name of the application.
I spent a good deal of time last night doing something very similar. The only real difference is my user object wasn't a File. I have it working but the code is a mess and there are specific things it to my project.
What I am going to attempt today is to yank it out into a sample application that I can share with you. I just didn't want you to think your thread is being ignored. But I might not have it until the end of the weekend. I'll just have to see how difficult it night be.
Thanks Gregg for the example and sorry for the late reply. I still don`t make it work when drop the file to the list is showing the same format file name "Test.FileTreeNode@1f78ef1" and i was tthinking that the "getUserObject()" is responsible for this.
It`s not necessary to use dnd i only want when selecting the files from the JTree to add the path+filename to the JList. I was thinking to make a popup menu when right click the mouse on the node and select for example "insert to list" and insert the path+filename.
It it possible to make it work on FileTreeNode or i have to use DefaultMutableTreeNode to get the corect path+filename?