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) {}

Similar Messages

  • I am using garage band for the first time.  I dragged and dropped a song from itunes into the program and I want to extend the length of the song by repeating the first 28 measures.  I can't figure it out.  Please help

    I am using garage band for the first time.  I dragged and dropped a song from itunes into the program and I want to extend the length of the song by repeating the first 28 measures.  I can't figure it out.  Please help.  I have spent several hours trying to figure it out on my own but have not been successful.  It seems like an easy task.  Can anyone help?

    dewin1or wrote:
    I want to extend the length of the song by repeating the first 28 measures.
    split the region at the 28th measure
    http://www.bulletsandbones.com/GB/GBFAQ.html#split
    (Let the page FULLY load. The link to your answer is at the top of your screen)
    then select only the first region and option-drag it to the end of the song

  • 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

  • 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 !

  • Safari for Mac, webpage with Java applet, drag and drop area not working.

    At my company, we have a web page that our users access to submit media files, (QuickTime, Audio, images...), for transcoding for delivery.  The web page consists of a java applet, with an area that our users drag and drop media file into.
    After updating to Safari 5.1.2, the applet will not work anymore. Instead, the browser will "open" the quicktime and play it, instead of allowing the Java Applet to do it's job.
    CAN I TURN THIS FUNCTIONALITY OFF??
    I read that Safari 5.1.2, (when it was initially released), broke something with the THEN current version of Java, and everyone was awaiting the latest update (build 1.6.0_29) to fix it. Unfortunately, this update did not fix my issue with the functionality of dragging and dropping media files into the web page.
    It seems to me, as if, there is an over-arching functionality setting (or something) that needs to be either turned off, or in some other way DE-prioritized.
    Anyone have any ideas?
    Safari 5.1.2
    MacOS 10.6.8
    MacBook Pro

    Thanks for quick reply and help. I am able to drag multiple files but this is giving problem in case of filename with spaces like "abc def.png". Can you please put some thoughts on this.
    DataFlavor uriListFlavor = new DataFlavor("text/uri-list;class=java.lang.String");
                   Reader in = (Reader)t.getTransferData(DataFlavor.plainTextFlavor);
                   BufferedReader br = new BufferedReader(in);
                   String uriStr;
                   while ((uriStr = br.readLine()) != null)
                       URL url = new URL(uriStr);
                       String category = GalleryUtils.contentsPanel.getCurrentCategoryPath();
                       GalleryUtils.generateILPFromFile(new File(url.getFile()), category);
                   }Thanks
    Kanni

  • 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)

  • 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..

  • 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.

  • 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

  • I have multiple libraries how can I drag and drop songs from either

    I have 3 PCs that are all authorized to play my music.  I have different music on different machines that I have downloaded from various places and or ripped from my own cds.  I can from my home PC drag and drop music and movies to my iPhone.  But on my work PC say if I download a new Album (not from itunes) and it is in my library, I want to be able to just drag it onto my iPhone so that I can listen to it at the gym.  When I do I see a small red circle with the red slash through it and i cant copy it.  I am tired of synching and want to be able to drag and drop from any of my PCs..  is this possible?

    My mistake totally!!! I confused a new playlist folder with a new playlist.
    Just wanted to pass that along.

  • Reorder items in JTree using drag-and-drop

    Title says it all: before I start re-inventing the wheel, any code out there?
    Think of the code that I need as an outliner.

    Did you ever find a solution to this. I'm looking to implement a similar interface using a JList where the user can reorder drawing layers by dragging and dropping.
    I'm temped to use a scrollpane and roll my own drag reorder code, so any supported behaviors would be welcome.
    thanks,
    Steven

  • Specify multiple correct targets in a drag and drop?

    Is it possible to specify more than one correct target in a drag and drop interaction (i am creating a quiz where the learner has to label a diagram of the urinary system and there are 2 kidney labels they have to correctly drop onto the diagram, however i would like either label to be correct if dragged onto the 2 kidneys - if i've explained this clearly?)

    Sorry, overlooked this question. Lot can be solved from that window, glad you found out yourself.

  • 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.

Maybe you are looking for