Drag n Drop in JTree - missing the visual effect

Hi,
I already implemented the D&D on Jtree (from a JList)
I've implemented DropTargetListener and it works
I've the visual effect of the Dragged object on the mouse
I have an extended DefaultTreeCellRenderer witch I use for other things.
My problem is how do I get the visual effect of the active tree nodes when I drag it over them ?
thanks,
Allen

Drag and drop is not something you can just turn on and off im afraid. You have 2 choices:
1. if the dragging and dropping only occurs over a single component such as your tree, you could probably make a simplified on with mouse [motion?] listeners. On a mouse drag it could check which node was under the drag point and keep that in a variable. On a mouse release it could look to see if theres a node there and if so make it a child of that node.
2. Implement full drag and drop, subclassing the JTree and having both a DragSource and DropTarget assigned to it. Theres a load of interfaces to implement but its not too difficult. Youll also need to make a DataFlavor class to contain the node values. Its the more involved solution but would probably be better in the long run.
DS

Similar Messages

  • How can I allow a learner to review a created Drag and Drop Quiz to show the learner their incorrect/correct answers?

    Captivate 8: I have created an assessment with two multiple choice question slides and eight drag and drop question slides. After the learner views their score, I would like them to be able to review all of their answers to see where errors were made. Currently, the review quiz only shows their answers and the correct answers for Multiple choice question slides. Ideally, I would like a review of the drag and drop question slides where the incorrect choices are outlined in red or something to this effect. I appreciate any insight and suggestions!

    Sorry, D&D is not a normal question slide and I can only recommend logging a feature request. I would really like to be able to choose whether an interaction is reset or not, because this problem doesn't exist only for D&D but for all learning interactions as well.

  • I would like to build a drag n drop interface and have the results sent to my email in PDF format. Is this possible?

    I would like to build a drag n drop interface and have the results sent to my email in PDF format. Is this possible?

    Captivate is not really designed to do what you want in this instance.  It's more targeted at allowing a user to complete an assessment and then track whether or not they passed.  So it's only really set up to send information in a format that the LMS will understand and interpret as Pass/Faill and what the score was.
    You really need something more flexible than that. So I think you would need to get a programmer involved and have the solution custom made.  In my experience, any time you try to diverge Captivate from what it was designed to do, and you need to get other IT professionals involved, you can kiss thousands of dollars goodbye before you have a workable solution.

  • I have the old ipod classic and cant drag or drop/update music on the new itunes?

    I have the old iPod classic and cant drag or drop/update music on the new iTunes?

    Try using this program to place the iPod in recovery mode
    RecBoot: Easy Way to Put iPhone into Recovery Mode
    You can also try:
    The Firmware Umbrella - TinyUmbrella

  • Drag-n-drop a file on the Browse button?

    Hi,
    Recently discovered I can drag-n-drop a file onto the Browse button in web applications prompting for file upload. Would like to find out more details about this capability. When was it implemented? What are the details of the implementation? Is it a standard capability I can count on for my application use?
    -Scott

    http://techreport.com/news/18147/firefox-3-6-supports-drag-and-drop-uploading
    https://hacks.mozilla.org/category/drag-and-drop/by/comments/as/complete/
    https://wiki.mozilla.org/Firefox/Feature_Brainstorming:Form_handling_and_text_areas
    Above link tells you about drag n drop feature of firefox along with video

  • Why won't Premiere Pro allow me to drag and drop my footage into the timeline?

    why wont my software allow me to drag and drop my footage into the timeline?
    [Edit: the title of your post was changed to be more descriptive]
    Message was edited by: Kevin Monahan

    Get Started with Premiere Pro
    New to Premiere Pro? Get started with your first project — editing a video. In less than an hour, you'll learn to edit together different types of media to tell a video story.  

  • The visual effects of iTunes don't appear :(

    Hi everybody! See, my cat decided two days ago to sleep on the keyboard of my portable computer while iTunes was on and now the visual effects don't work. The screen simply stays black. I don't know which key was pressed or whatever... I have even reinstalled iTunes but it still doesn't work well. Any ideas? Thank you...

    Every version of iTunes that supports syncing with an iPhone has the ability to sync pictures to the device.
    Resize the iTunes windowso that you can see the entire window.

  • Drag and Drop in JTree

    Hello
    i have developped sucessfully the drag on drop operation in my JTree and it works well but now i will also change the cursor of the mouse.
    so if you drag and drop an object in a jtree you must view the movement of that object, i think that it may be possible to change the cursor of the mouse to do that but i don't know how it works
    Is it also possible that the entire structure under the moved node is visible during moving?
    I hope that somebody can help me
    Jeff R.

    here is the code for the drag and drop operation
    public class TreeListener implements TreeSelectionListener,MouseListener,                               DragGestureListener, DropTargetListener,DragSourceListener{
         private CatalogManagerFrameListener frame;
         private CatalogElement selectedElement;
         /** Variables needed for DnD */
         DragSource dragSource = DragSource.getDefaultDragSource() ;
         private TreePath selectedTreePath;
         /** DragGestureListener interface method */
         public void dragGestureRecognized(DragGestureEvent e) {
         JTree tree = (JTree)e.getComponent();
         //Get the selected node
         if (selectedElement != null) {
              //Get the Transferable Object
              Transferable transferable = (Transferable) selectedElement;
              //Select the appropriate cursor;
              Cursor cursor = DragSource.DefaultMoveDrop;
              tree.setCursor(cursor);
              //begin the drag
              dragSource.startDrag(e, cursor, transferable, this);
         /** DropTargetListener interface method - What we do when drag is released */
         public void drop(DropTargetDropEvent e) {
              JTree tree = (JTree)((DropTarget)e.getSource()).getComponent();
              try {
                   Transferable tr = e.getTransferable();
                   //flavor not supported, reject drop
                   if (!tr.isDataFlavorSupported(CatalogElement.INFO_FLAVOR)){
                        e.rejectDrop();
                   //get source
                   CatalogElement source = selectedElement;
                   //get new parent node
                   Point loc = e.getLocation();
                   TreePath destinationPath = tree.getPathForLocation(loc.x, loc.y);
                   CatalogElement destination = (CatalogElement) destinationPath.getLastPathComponent();
                   if (testDropTarget(destinationPath, selectedTreePath)) {
                        move(source,destination);          
                        destinationPath.pathByAddingChild(source);
                        tree.setSelectionPath(destinationPath);
                   else{
                        e.rejectDrop();
              catch(Exception ex){     
                   e.rejectDrop();

  • Drag and Drop between JTree and another component

    Hi,
    I have searched the forum for answer to this question but am not sure I found something similar to this. So, please help me out on this.
    I have a JTree and a JPanel, which basically shows images (as thumbnails) for the child nodes of one node in the tree heirarchy.
    I need to be able to drag and drop components from the JPanel to the JTree and vice versa, and of course, when you drop them on the tree, they should go under the correct node.
    I am using Swing 1.4.1, and have successfully implemented DnD in the JTree itself. But I am a little unclear about the DnD between the tree and the panel.
    Would really appreciate if someone could throw some light on this.
    Thanks a lot,
    Sri.

    Hi clairesheridan,
    thanks for your response. Your answer would have helped me if I was using JDK 1.3 but I am try to use the Swing API in jdk1.4.1, in which you have to set a transferhandler etc.
    Please let me know if you have any ideas or solutions.
    Thanks,
    sriharmya.

  • Drag and Drop between JTree and Labels in 2 different panes

    Hi,
    I am using JDK 1.4.1 and am trying to implement Drag n Drop between a JTree and JLabels with ImageIcons, both on different panes.
    I got the DnD working fine on the tree. but i cant get to drag and drop the label from the other pane, on the Jtree as a node. I am getting confused with the DataFlavors, and also wonder if there is something else that i have to do for DnD between 2 panes. Can someone give me any leads on this, please? The Panes I am talking about are splitpanes.
    thanks,
    Sri.

    hey thanks Dennis!! I was hoping you would respond to my question, as I have seen a lot of your replies. yes, the example you gave would be helpful. but i am trying to implement this in 1.4.1, with the new drag and drop in swing. and i am getting confused wiht theh data flavors etc.
    my problem at hand is :
    I have a tree on the left pane. i can drag and drop the nodes on the tree itself. (i already did that...no problem). I have Jlabels with imageicons (actually wrapper classes with labels and imageicons) on the right pane. i have to be able to drag these labels to the tree such that they form a node.
    I have one class the NodeSelection class which extends TransferHandler and implements Transferable. i was able to do DnD for the tree using this. I customized the importData method in this.I thought that i can just use the same class to create the transferhandler and transferable, and just use a different implementation for the importData method if the data being dragged is from the label.
    well, my thoughts and ideas were ok...but i can implement it...so they must be wrong ;-)
    Can u please suggest another way to do this. I have a deadline to meet and am stuck here :-( any suggestions or tips or hints would be very helpful and appreciated!!
    Thanks,
    Sri.

  • How to Drag and Drop mutliple rows in the jtable

    hai
    i am having a jtree ,in which i added many nodes,each nodes hav
    corresponding jtable with values. now i need to drag a group of rows from a jtable of particular node in jtree to another node.
    at the same time i am possible to drag and drop the single row in the same sceanrio which i mentioned above.
    how to do this,can anyone pls help me regarding this
    goutham

    The Swing tutorial on [url http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html]How to Use Drag and Drop has an example with JTable support.

  • Drag n Drop in JTree

    Hi,
    I am working on a prototype that requires drag and drop operation on a JTree. My applet requires to drag a item from the list into a JTree. I could achive this in the Frame and appletviewer, but when it comes to browser the drag and drop does not take place. I would appreciate if anyone could give a solution to this.
    Thanks,

    Does anyone of you able to work with drag n drop in Applet.
    I am not able to achieve that,if someone has done that do help me.
    Moreover we need to specify some security privileges if we need to run the drag n drop in an applet isnt it??
    how to do that. in browser specialy. How to use the policy file?
    thanking in advance

  • When I drag and drop an icon from the address bar to the desktop is does creat the shortcut but will not display the website icon, only the firefox icon, how can I display website icons?

    When I drag and drop a website icon from the Forefox address bar to the desk top, the short cut is created but the icon that appears is the firefox Icon. I want to disply the icon from the website that the short cut refers to. I have checked all I can think of in my computer to no avail.

    You have to assign the favicon yourself to the desktop shortcut (right-click the shortcut: Properties) after you have dragged the link to the desktop.
    You can usually find the favicon in Tools >Page Info > Media and save the icon there.
    Otherwise use the main domain of the website and add favicon.ico (e.g. mozilla.com/favicon.ico ) to display the favicon in a tab and save that image to a folder.

  • Itunes won't let me drag-n-drop .m4r files into the 'TONES' library (for ringtones)

    Can anyone help?  I have created ringtones by converting my song to AAC, then shortening it to 40 seconds, then saving it as .m4r file extention.  I have changed my preferences to show "Tones" library in my iTunes.  Only problem is, iTunes won't accept the ringtone when I try to add it.  I tried to add it by grabbing it from Finder and dropping it into iTunes...but nothing adds???  Any suggestions?

    In order to drag and drop, you need to have the box next to "Manually manage..." on the iPad summary pane checked.
    This was changed (in V 10.0?)
    Items dragged to the iPad/iPod will still get copied over, even when not manually managing.
    Select the tabs across top and the dragged items show up at the very bottom under *Manually added*.

  • Drag and drop in JTree's

    Hello,
    How/can do you do drag and drop of elements within or between JTree's.
    I am working on a bookmark editor program and need a tree control for sorting bookmarks in a heirachy.
    I would like some sort of insert line to appear between elements as an element is dragged, showing where it would go when droped.
    Also I want to be able to mark multiple elements for dragging.
    And also to be able to drag elements between trees.
    Is this in Swing an if so how do you program it ? And if not, how/can you go about adding this facitity.
    I am not asking for too much :) An I?
    Are there any open source programs that exhibit any of these behavious that I can use as a guide ?
    Hope you can help. Many thanks,
    Aaron - [email protected]

    http://search.java.sun.com/search/java/index.jsp?col=javaforums&qp=&qt=%2Bdnd+%2Bjtree

Maybe you are looking for

  • Help creating an external array for a scoreboard

    I'm trying to create an array in an external file that will recieve and arrange scores sent from Quiz.fla upon clicking the submit score button.  I also want another fla file to be able to reference this external array and pull the top 15 scores from

  • Will Windows 7 home Premium/Basic 64 bit Support FMLE 3.1

    hi there I am planning to buy dell inspiron laptop which comes with Windows 7 Home Premium/Basic 64 bit.Will this OS support FMLE 3.1 ?

  • Urgent ...how to send output of sap through mail

    Could you please guide me how to send output of SAP Script  through mail in PDF format. Thanks in Advance.... Regards, Kumar.

  • 'Error Occured in the Source System' for Non SAP system

    Hi Gurus, We have an Info Package which is getting the data from the Source System 'DOCP' and it has failed due to 'Error Occured in the Source System'.Since the source system is Non SAP system there is no option 'Replicate Data Sources'.So,First I a

  • Sm basic intervw questions

    1)What are selection texts? why do we use it? 2)What is the significance of HIDE? Where do u code the HIDE statement? 3)What are different tools to report data in SAP? What all have      you used? 4)When a program is created and need to be transporte