Display JTree Node as image  while Drag And Drop

HI all.
I have multiple 5 JTrees which involve drag and drop to each other . I would like to display the node(JCompenent) as image/cursor which a DnD operation .So that user could see what he drags .
I tried out the example about ghost image .
http://www.javaworld.com/javaworld/javatips/jw-javatip114.html
This works fine ,but when i apply the same concepts to my application it doesnt work .
Could any one suggest what could be problem.
Cheers,Baiju

I also need to drag my node on my scene during a "drag and drop" operation. But i can't find a solution.
I've tried to use "startFullDrag()" and catch MouseDragEvent, but nothing ...
Can anyone help me ?
Thank !

Similar Messages

  • Ghost image for multiple selection in JTree while drag and drop.

    I am unable to create a Ghost image for drag and drop with in the JTree for multiple selection, i got some examples but all are for single selection ,
    Idea of creating buffered image is good , but unable to create it for multiple selection , tried a lot but got weird results.... can any body give me any clue about this , if got any example that will be fantastic.
    Thanks & Regards
    Sandeep Mandori

    sandeep_mandori wrote:
    I am unable to create a Ghost image for drag and drop with in the JTree for multiple selection, i got some examples but all are for single selection ,
    Idea of creating buffered image is good , but unable to create it for multiple selection , tried a lot but got weird results.... can any body give me any clue about this , if got any example that will be fantastic.
    Thanks & Regards
    Sandeep MandoriTry this:
        private TreePath[] dragPath;
        private BufferedImage[] image;
        private void createDragImage(JTree tree) {
            if (dragPath != null) {
                try {
                    image = new BufferedImage[dragPath.length];
                    for (int i = 0; i < dragPath.length; i++) {
                        Rectangle pathBounds = tree.getPathBounds(dragPath);
    TreeCellRenderer r = tree.getCellRenderer();
    DefaultTreeModel m = (DefaultTreeModel)tree.getModel();
    boolean nIsLeaf = m.isLeaf(dragPath[i].getLastPathComponent());
    MutableTreeNode draggedNode = (MutableTreeNode) dragPath[i].getLastPathComponent();
    JComponent lbl = (JComponent)r.getTreeCellRendererComponent(tree, draggedNode, false ,
    tree.isExpanded(dragPath[i]),nIsLeaf, 0,false);
    lbl.setBounds(pathBounds);
    BufferedImage img = new BufferedImage(lbl.getWidth(), lbl.getHeight(),
    BufferedImage.TYPE_INT_ARGB_PRE);
    Graphics2D graphics = img.createGraphics();
    graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
    lbl.setOpaque(false);
    lbl.paint(graphics);
    graphics.dispose();
    image[i] = img;
    } catch (RuntimeException re) {}

  • Unable to send or recieve images via drag and drop?

    I am unable to send or recieve jpg and gif images by dragging and dropping from finder. How do I fix this?

    Hi,
    Where are you dragging them to ?
    You Can do it two ways using Drag.
    One is to the Buddy's Name in the Buddy list and letting go  (it gets sent as a loose file)
    The Second is to drag it to the Text field during a Text chat (Excluding Group Chats)
    The First causes an Invite to accept to pop up on the Buddies Screen.
    You can also see see when it is Accepted (you may even have to confirm sending depending on your Settings)
    The Second gets sent as a File Link in the Chat which the Buddy has to Also Accept...
    You can also send files by highlighting a Buddy and going the the Buddies Menu > Send File.
    This method tends to point to error with the File Transfer port not being open.
    So...
    Check you can send Files first by all three methods.  (these tends to ignore  Firewall and Router settings as it is Outgoing)
    Get your Buddy to Send by all three methods.
    IF this is AIM and you are having issues log out of the Account  (IChat > Preferences > Accounts > Account Info Tab (Deselect "Use this Account")
    Now go to the Sever Settings
    Change the Default port from 5190 to 443.
    iChat Logs in on port 5190 using the TCP Protocol.
    File Transfers or Direct IMs when done in a Chat are sent on Port 5190 but on the UDP Protocol (It is Peer-to-Peer).
    Some Router don't like this dual Use.
    If you still have issues then you will need to either Enable the Firewall and check iChat in in the List of allowed Apps and/or open  port 5190 in you router. (on the UDP Protocol if stated)
    10:22 PM      Wednesday; September 28, 2011
    Please, if posting Logs, do not post any Log info after the line "Binary Images for iChat"
     G4/1GhzDual MDD (Leopard 10.5.8)
     MacBookPro 2Gb( 10.6.8)
     Mac OS X (10.6.8),
    "Limit the Logs to the Bits above Binary Images."  No, Seriously

  • Keyboard shortcuts while dragging-and-dropping?

    In Windows, when I'm dragging and dropping files from one folder to another, I can press keys on the keyboard to force it to change its behaviour -- for example, if I hold the Crtl key down, it will force it to copy files instead of move them.  Similarly, I can hold down the shift key to force it to move files when it wants to default to copying them.
    What is the equivalent keypress on a Mac running OS X 10.9.2?  It keeps moving files when I want to copy them (and vice-versa) and I just can't figure out which key(s) to press while dragging-and-dropping to make it change its behaviour.
    Thanks for your help,
    Laurence MacNeill
    Mableton, Georgia, USA

    Press the Option key to force a copy, or the Command key to force a move. Pressing both at once will create an alias.
    (103123)

  • SecurityException while drag and drop ??

    hi group,
    i am getting security Exception while drag and drop.
    Any body can find this bug...
    Exception occurred during event dispatching:
    java.security.AccessControlException: access denied (java.awt.AWTPermission acceptDropBetweenAccessControllerContexts)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at sun.awt.windows.WDropTargetContextPeer.getJVMLocalSourceTransferable(Unknown Source)
    at sun.awt.windows.WDropTargetContextPeer.processEnterMessage(Unknown Source)
    at sun.awt.windows.WDropTargetContextPeer.run(Unknown Source)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.Dialog.show(Unknown Source)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
    thank u..

    hi,
    your problem might be due to any of the following
    1. No java 2 plugin - install it.
    2.drag & drop between AWT & Swing Frames(windows)
    3. Add the following text to your java.policy file and restart your computer.
    grant {
    permission java.awt.AWTPermission "accessEventQueue";
    permission java.awt.AWTPermission "setDropTarget";
    permission java.awt.AWTPermission "accessClipboard";
    permission java.awt.AWTPermission "acceptDropBetweenAccessControllerContexts";
    permission java.awt.AWTPermission "listenToAllAWTEvents";
    please let me know if this works.
    good luck

  • Close folders while drag-and-dropping files?

    When dragging files to move them, often some large folders will be open, which means I have to drag/scroll thru the file list to get to other folders. Is there a way to close folders while dragging files?

    EMichaelM wrote:
    I just installed two widgets that are supposed to function by dragging and dropping files into them. How do I get access to files? How do you get files from the Finder into the dashboard?
    You need to activate Dashboard's "Developer Mode" in order to keep widgets active on the desktop.
    Open Terminal and enter the following command:
    <PRE>
    defaults write com.apple.dashboard devmode YES
    </PRE>
    Close Terminal, log out of your user account, and log back in again. To move a widget onto your desktop, activate Dashboard and start dragging the widget to the desktop. Press F12 before letting up on the mouse button to close Dashboard, and the widget should now be permanently affixed to the desktop. Drag to your desired location.
    Steve

  • Error while drag and drop photo from Iphone to PC

    My PC OS: Window Vista 32bit
    when I connect iphone to PC. I can access iphone by Portable device->My Iphone-> Internal storage-> DCIM->100apple-> xxx.jpg
    and when I copy the pic and paste it to my PC, or drag and drop photo from Iphone to PC, it fail and show below error and force to close all explorer.
    Problem name: BEX
    Program name: explorer.exe
    problem version: 6.0.6001.18164
    Error module name: wzshlex1.dll
    Error module version: 4.1.8477.0
    blah blah
    and now I cannot delete DCIM file. while I try to delete it, a message said the device no response.
    and I found one thing, I use a "iphone photo" program to check photos in Camera Roll, it show 2 pics that cannot be show when I use explorer browse the folder.
    who can help me?

    hmm fixed by uninstall winzip
    thats interesting..

  • Error while drag and drop in OAWD transaction

    Hi Expert,
    One of my user is trying to attach a document through Drag and Drop in OAWD transaction after he attaches a document and when he cancels on the cancel button he is getting the following error:
    Crtical error during Archiving: Archiving Directory cannot be created. The Archiving procedure will be aborted.
    Please help to resolve this issue.
    Thanks in advance.

    Hi Babu Nair, how did you solve this issue?
    Rgds,
    Nanie

  • Problem using text boxes as the "image" to drag and drop over audio file

    I have been adding audio files to my page in iWeb (previous version, not '08), but I am having a problem giving them titles.
    When you first drag a file from iTunes into iWeb, it provides a space for you to drag and drop a picture. The online iWeb guide also says that you can drag a text box there instead of a picture.
    I created a text box with the text I would like to drop over the controller. However, it is no longer allowing me to drop the text box there. I used to be able to do this, and I don't know what I'm doing differently now. Any suggestions?
    Thanks!
    -- Will

    foobar2000 with the ipod plugin will allow you to drag/drop FLAC files and when it syncs the ipod, it converts the FLAC files on the fly. MUCH better than dealing with the crappy iTunes interface and having to pre-convert the files. I absolutely loathe iTunes and it just gets worse and worse!

  • Is there a way to move images without dragging and dropping?

    I am trying to drag and drop files out of one folder and put into a subfolder in the library module but it wont let me and I am wondering if there is a navigation menu that will allow me to do the same?

    Drag and drop should work.
    Make sure when you begin the drag, you are pointing at the photo itself and not the grey rectangle around the photo.
    There is no menu command.

  • Getting a stop  symbol while dragging and dropping in IE9 and IE8

    Hello,
    I have implemented the drag and drop of row in a table. The functionality is working fine but in IE 8 and IE9 when I drag and drop the row over another row it is showing a stop sign, though in-spite of that stop symbol the drag and drop is working fine. I am using jdev 11.1.1.6
    Thanks
    Tarun

    Hi,
    The cursor is under the control of the drag and drop framework during drag and drop operations. So if the behavior is normal on FF and /or Chrome and you have a support contract, please file a service request asking the analysts to look at your test case. Alternatively you can try and set.
    If you don't have a support contract (still we are interested to get this issue checked), please send a test case to myself (mention your OS and the exact IE versions - you find that in the Help / About). In the latter case zip the workspace, rename the zip to unzip and use the mail address in my OTN profile.
    Frank
    Disclaimer: Bugs I file flagged "internal" and not visible outside of Oracle. In addition I don't track bugs to provide status updates.

  • While dragging and dropping text on Mail sometimes is copied instead of moved

    When composing a message under Mail it happens that a word needs to be cut from a place and paste somewhere else in the body. Instead of cutting&pasting most text editors allow the user to drag the selected word (or consecutive words) and drop them as desired. Well, why on earth Mail sometimes actually moves the selected words while sometimes it copies words?
    I reported this bug already under Mountain Lion, but it hasn't been fixed yet. Text Edit, built in as well as Mail, works properly.

    Press the Option key to force a copy, or the Command key to force a move. Pressing both at once will create an alias.
    (103123)

  • Placing text component on an image by drag and drop

    Hi evrybody...
    I need to place annotation on the images.
    As part of that i need to drag text component on that image.
    I have no idea of doing this...
    If any body can help ..it is great....
    Thanks in advance...

    Turn off the Runaround settings on the image.

  • How to disable ctrl,shift while drag and drop

    after starting the drag, i donnot want the user to change action with ctrl & shift. how can i do that?

    The Error Console click is visible in Tools of FireFox 3.6.8. Against it is mentioned the shortcut key Ctrl+Shift+J. How can I do away with this shortcut key? If I want to see the Error Console, I can click at it. This shortcut key of FireFox is interfering with this very shortcut key on InfraWare Transcription Client 2009 on which I work online and which is set to run on Internet Explorer only.
    I thank you for asking me to go through a whole gamut of an article on Key Configuration much of which is Greek to me. I am getting nowhere doing that.

  • Tree node to respond to the drag and drop...

    I have to be able to drag a file into a tree node to drop.
    When I drop at the tree node, the file should be shown at the right side of panel. Just like MS Window Explorer.
    Drag and drop at the table to table is working but not drag into the tree and automatically moves into the tree... is...
    Any idea would be welcomded.

    You'll need to setDragEnabled and write a TransferHandler for the JTree. See Introduction to Drag and Drop and Data Transfer.

Maybe you are looking for