Drag Drop icon/image in JApplet

Hi! I would like to implement a Drag Drop of images/icons between two JPanels in a JApplet. Can someone give me a working example of the code that I have to implement ???
Thanks to you !!!!
TGuido

This should help:
http://java.sun.com/docs/books/tutorial/uiswing/misc/example-1dot4/index.html#BasicDnD

Similar Messages

  • Drag/Drop Proxy Image

    I would like to be able to access the Proxy Image during a
    drag/drop operation inside the DragOver event. Is it possible to
    get refernce to that object to be able to change the image, get
    it's current location, etc?

    1. Using canvas in flash is uncommon, even in Flex its a class that has been replaced by more flexible solutions since flex 4: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/containers/Canvas.ht ml
    2.Shouldn`t your localToGlobal method not starting from canvas ? Instead of image? Not sure how you setup your whole application)
    http://www.orlandmedia.com/blog/tutorials/how-to-use-localtoglobal-in-actionscript-3-0/

  • Drag/Drop cursor image

    I have a problem with the cursor image during a drag operation. I can successfully set the cursor image (to crosshair) onMousePressed as seen here:
    https://picasaweb.google.com/106701681904956191227/January202012#5699582095046710866
    when I begin dragging the cursor, the crosshair disappears and is replaced with a "document" image as seen here:
    https://picasaweb.google.com/106701681904956191227/January202012#5699582124535625250
    and it covers the drop target.
    How do I keep the crosshair cursor all the way through to the drop completion?

    How do I keep the crosshair cursor all the way through to the drop completion?I tried this on Windows and there is no way to change the default cursor while dragging.
    For example once the drag event has started if you try to set the cursor on the scene, the request to change the cursor won't take effect until after the drag and drop operation has completed.
    I guess Macs works the same as windows in this regard, just with different icons.
    The default drag and drop cursors for windows are a circle with a line through it while dragging if not over a drop target and a pointer with a question mark if over a drop target.

  • When I import or drag/drop an image from Finder into Pages, it floats the image instead of keeping it inline with text

    I'm new to Pages and I've searched online for an answer to this question but haven't found anything quite what I need.
    When I import an image from Finder (or drag and drop from Finder) into Pages, the Text Wrap default is "automatic" which seems to be "in front of text." I have to manually click each image and then change it from "Automatic" to "Inline With Text." Is there a way to change the default so it's not "Automatic" but "Inline With Text" to save me these steps for every single image I import?
    (If importing from Media Browser would behave differently, I don't use iPhoto except for Photo Stream so I need to bring them in from where I've saved them in my Finder.)
    Thanks so much for any help!

    Good questions...  I'll have to try and figure out when the problem first happened - I was thinking it was when I upgraded to Safari 5.1.4 but that might not be the case...  I'll try your suggestions to see if any of them eliminate the problem (I have restarted recenlty and that didn't fix it) but I'll try repairing permissions,etc.  Thanks!
    hmmm... Mcbuffy: are you implying that you *don't* get the webloc when dragging an image out of Safari and that this isn't a caused by change to Safari but is a big/conflict in mine?

  • Drag Drop images/icons JApplet

    Hi! I would like to implement a Drag Drop of images/icons between two JPanels in a JApplet. Can someone give me a working example of the code that I have to implement ???
    Thanks to you !!!!
    TGuido

    The standard procedure is to post a small message to make your old post go to the top

  • R6034 error Photoshop CS2 drag & drop

    I've had this problem for some time.  I'm on Vista-64-SP2 running Photoshop-CS2 When first installed PS-CS2 worked fine. I got no errors when starting the program and I could drag & drop icons from the desktop or windows onto the Adobe taskbar icon and the photo would load normally.
    Then I let Adobe automatically upgrade my CS2 and other Adobe products (Dreamweaver CS4, Illustrator CS2, GoLive6, Reader, Flash browser plug-in, etc.) and then I started getting a windows error message R6034 saying that "An application has made an attempt to load the C runtime library incorrectly."  Microsoft says the fix is to recompile the application.  Yeah right!
    OK, so I delete Photoshop and other applications and reinstall them all and the problem goes away ... until I let Adobe automatically update the products and the problem comes back.  Yes, I can probably live with an unupdated virgin version of Photoshop CS2 but there should be an answer from Adobe or at least someone else to validate that my complaint is not unique.
    Another problem that may be related is that I've seemed to have lost the ability for Adobe GoLive6 to open Photoshop images for editing
    Also I've lost the ability to drag & drop from the desktop or a window onto an open Photoshop application or onto its icon on the taskbar.
    I've searched the web and find nothing similar.  The solutions I have found were unrelated to my situation or were for a Macintosh.  I've searched the forums here and find nothing that gives an answer.
    I know pretty much what I'm doing around computers and I keep a clean system.  Informed replies are most appreciated.

    I don't think you will have much luck on that one. The problem here clearly is the way 32bit DLLs need to be piped on 64bit systems, which for some reason does not seem to work in your case, probably due to soem registry key being changed and then it messes up the wghole OLE/ DDE/ COM shebang. It may be further complicated by some dispaly routiner incompatibility. Since CS2 was never developed with Vista 64 in mind, you can't even exactly blame someone and this seems a common problem with an assortment of legacy apps, not just Adobe programs. What you could try is to download Sysinternals' Process Monitor, establish a filter rule specific to the updater and see, which registry keys it changes, which DLLs it replaces etc. this may then offer some clues as to which ones you need to salvage before the update and may possibly put back into place thereafter. May work, may not, but in any case you are doing it on your own responsibility....
    Mylenium

  • Which Listener I should use if I drag and Drop an image/icon into a JPanel?

    Dar Friends:
    Happy new year.
    I try to drag and Drop an image/icon into a JPanel, and hope I can immediately detect it after DND,
    Which Listener I should use in this JPanel if I drag and Drop an image/icon into a JPanel??
    Thanks

    Thank camickr .
    I can dnd an image into a JPanel called JPanelOld already, I hope to use another JPanel or JTree to listen to any Dropped Image in JPanelOld later on so I can take some action in another JPanel or JTree.
    so what kind of Listener I should use for my purpose??
    where to add this Listeners??
    Happy New Year.

  • How can I drag and drop an icon/image into a panel??

    Dear Friends:
    How can I drag and drop an icon/image from one panel into another target panel at any position in target panel at my will??
    any good example code available??
    I search for quite a while, cannot find a very good one.
    please help
    Thanks
    Sunny

    [url http://java.sun.com/developer/JDCTechTips/2003/tt0318.html#1]DRAGGING TEXT AND IMAGES WITH SWING

  • Can't drag disk icon in Disk Utility to restore backup image

    I'm restoring my MacBook from a backup image I made on my external HD with SuperDuper! and I've run into a big problem. I've booted from my OS X CD. I'm in Disk Utility, and while my external drive mounts and I can select the image in the 'restore' pane, I can't for the life of me drag any icon to the 'destination' field. Any help with this?

    Hi
    I have exactly the same problem,i backed up my internal HD, and want to restore it by starting my mac mini intel single core with the original delivered os dvd including diskutilities.But no way it is not possible to drag a volume or partition to the required field to the left.I called apple support and the guy did not understand what I'm talking about at all, and told me he will forward to the developer dep.
    Never mind, I recovered the mac mini intel with ccc , thanks God I did an image backup and a ccc !
    Yesterday my mac mini intel audio hardware has broken, so I have to do another bkp with booted up os dvd to bring in to a serviceprovider.
    Tried to recover for security issues , but disk utilitiy did not work again , no drag 'n' drop possible - this problem never exists under powermac before and its driving me mad under intel macs
    I did a trick to show thats it is definitely the revision of this os dvd and disk utilities (x86 intel rev.)
    I did a clean install form this os dvd, then cloned the interal harddisk to a external firewire disk making it bootable (using ccc for all)
    I did no software update just clean from the dvd, restarted , choosed external firewire harddisk, et voila - opened disk utilitiy to restore dmg image for the internal hd and drag 'n' drop works without problems!!
    Resumee:
    my delivered os dvd 10.4.5 AHT vesrion 3A102 disc version 1.0 2Z691-5738-A has the biggest bug of all, it can not recover a backed up image at all - that is a revision e.g. release bug (error).
    I will have to return this dvd !
    Greetings Tobias

  • Drag and drop icons from onside of the split pane to the other side.

    Hello All,
    I am tring to write a program where i can drag and drop icons from the left side of the split pane to the right side. I have to draw a network on the right side of the split pane from the icons provided on the left side. Putting the icons on the labels donot work as i would like to drag multiple icons from the left side and drop them on the right side. CAn anyone please help me with this.
    Thanks in advance
    smitha

    The other option besides the drag_n_drop support
    http://java.sun.com/docs/books/tutorial/uiswing/dnd/intro.htmlis to make up something on your own. You could use a glasspane (see JRootPane api for overview) as mentioned in the tutorial.
    Here's another variation using an OverlayLayout. One advantage of this approach is that you can localize the overlay component and avoid some work.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.BufferedImage;
    import java.io.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import javax.swing.event.MouseInputAdapter;
    public class DragRx extends JComponent {
        JPanel rightComponent;
        BufferedImage image;
        Point loc = new Point();
        protected void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                                RenderingHints.VALUE_ANTIALIAS_ON);
            if(image != null)
                g2.drawImage(image, loc.x, loc.y, this);
        public void setImage(BufferedImage image) {
            this.image = image;
            repaint();
        public void moveImage(int x, int y) {
            loc.setLocation(x, y);
            repaint();
        public void dropImage(Point p) {
            int w = image.getWidth();
            int h = image.getHeight();
            p = SwingUtilities.convertPoint(this, p, rightComponent);
            JLabel label = new JLabel(new ImageIcon(image));
            rightComponent.add(label);
            label.setBounds(p.x, p.y, w, h);
            setImage(null);
        private JPanel getContent(BufferedImage[] images) {
            JSplitPane splitPane = new JSplitPane();
            splitPane.setLeftComponent(getLeftComponent(images));
            splitPane.setRightComponent(getRightComponent());
            splitPane.setResizeWeight(0.5);
            splitPane.setDividerLocation(225);
            JPanel panel = new JPanel();
            OverlayLayout overlay = new OverlayLayout(panel);
            panel.setLayout(overlay);
            panel.add(this);
            panel.add(splitPane);
            return panel;
        private JPanel getLeftComponent(BufferedImage[] images) {
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.weightx = 1.0;
            gbc.weighty = 1.0;
            for(int j = 0; j < images.length; j++) {
                gbc.gridwidth = (j%2 == 0) ? GridBagConstraints.RELATIVE
                                           : GridBagConstraints.REMAINDER;
                panel.add(new JLabel(new ImageIcon(images[j])), gbc);
            CopyDragHandler handler = new CopyDragHandler(panel, this);
            panel.addMouseListener(handler);
            panel.addMouseMotionListener(handler);
            return panel;
        private JPanel getRightComponent() {
            rightComponent = new JPanel(null);
            MouseInputAdapter mia = new MouseInputAdapter() {
                Component selectedComponent;
                Point offset = new Point();
                boolean dragging = false;
                public void mousePressed(MouseEvent e) {
                    Point p = e.getPoint();
                    for(Component c : rightComponent.getComponents()) {
                        Rectangle r = c.getBounds();
                        if(r.contains(p)) {
                            selectedComponent = c;
                            offset.x = p.x - r.x;
                            offset.y = p.y - r.y;
                            dragging = true;
                            break;
                public void mouseReleased(MouseEvent e) {
                    dragging = false;
                public void mouseDragged(MouseEvent e) {
                    if(dragging) {
                        int x = e.getX() - offset.x;
                        int y = e.getY() - offset.y;
                        selectedComponent.setLocation(x,y);
            rightComponent.addMouseListener(mia);
            rightComponent.addMouseMotionListener(mia);
            return rightComponent;
        public static void main(String[] args) throws IOException {
            String[] ids = { "-c---", "--g--", "---h-", "----t" };
            BufferedImage[] images = new BufferedImage[ids.length];
            for(int j = 0; j < images.length; j++) {
                String path = "images/geek/geek" + ids[j] + ".gif";
                images[j] = ImageIO.read(new File(path));
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.add(new DragRx().getContent(images));
            f.setSize(500,400);
            f.setLocation(200,200);
            f.setVisible(true);
    class CopyDragHandler extends MouseInputAdapter {
        JComponent source;
        DragRx target;
        JLabel selectedLabel;
        Point start;
        Point offset = new Point();
        boolean dragging = false;
        final int MIN_DIST = 5;
        public CopyDragHandler(JComponent c, DragRx dr) {
            source = c;
            target = dr;
        public void mousePressed(MouseEvent e) {
            Point p = e.getPoint();
            Component[] c = source.getComponents();
            for(int j = 0; j < c.length; j++) {
                Rectangle r = c[j].getBounds();
                if(r.contains(p) && c[j] instanceof JLabel) {
                    offset.x = p.x - r.x;
                    offset.y = p.y - r.y;
                    start = p;
                    selectedLabel = (JLabel)c[j];
                    break;
        public void mouseReleased(MouseEvent e) {
            if(dragging && selectedLabel != null) {
                int x = e.getX() - offset.x;
                int y = e.getY() - offset.y;
                target.dropImage(new Point(x,y));
            selectedLabel = null;
            dragging = false;
        public void mouseDragged(MouseEvent e) {
            Point p = e.getPoint();
            if(!dragging && selectedLabel != null
                         && p.distance(start) > MIN_DIST) {
                dragging = true;
                copyAndSend();
            if(dragging) {
                int x = p.x - offset.x;
                int y = p.y - offset.y;
                target.moveImage(x, y);
        private void copyAndSend() {
            ImageIcon icon = (ImageIcon)selectedLabel.getIcon();
            BufferedImage image = copy((BufferedImage)icon.getImage());
            target.setImage(image);
        private BufferedImage copy(BufferedImage src) {
            int w = src.getWidth();
            int h = src.getHeight();
            BufferedImage dst =
                source.getGraphicsConfiguration().createCompatibleImage(w,h);
            Graphics2D g2 = dst.createGraphics();
            g2.drawImage(src,0,0,source);
            g2.dispose();
            return dst;
    }geek images from
    http://java.sun.com/docs/books/tutorial/uiswing/examples/components/index.html

  • Icon for Drag&Drop

    hello,
    does anybody known or has anybody a special icon for Drag&Drop (something like copy or delete icons) ?
    thank yuo very much for each answer!
    regards,
    Joana

    Try looking in jre/lib/images/cursors

  • Drag & drop images from Finder into new Photoshop layer?

    Is it possible to drag & drop images from Finder into a new Photoshop layer?
    I can do it from a web browser, but not the Finder.

    >I couldn't find a way to do so in Bridge, but also I never use that program. Never got into Bridge's workflow. >
    I really do suggest that you re-visit Bridge especially the CS4 version.
    I just cannot conceive of trying to use a Digital camera, a Scanner or the Creative Suite programs without using Bridge and ACR.
    I can even use it to read PDFs and inDesign documents (all pages!) without opening Acrobat or InD..
    >I usually keep a "work" window open with all the files I am using for a project, so it would be far more handy to be able to skim them in the Finder.
    It is now far more effective and efficient to do that in Bridge than in the Finder.
    This is where you would find the new Collections feature to be invaluable:
    Just select all the images and other files connected to a project from any folder and drag their icons into the same Collection.
    You then have all aliases (previewable at full-screen slide-view size with one click of the space bar in CS4) to ALL of your files which are now visible in. and openable from, a single panel.

  • A icon for drag&drop

    hello,
    could you say, how does a icon for drag&drop look? or where can I get it?
    I would put the icon in my java-program.
    thans a lot for each answer!
    best regards,
    joana

    Try looking in jre/lib/images/cursors

  • Drag and Drop and Image Size

    I need to be able to drag and drop images but I need them to be a certain size when I drag them out of an Aperture project. For various reasons, I don't want to use the export function. Only drag and drop will be efficient for the workflow that I"m planning. Problem is, the pixel dimension is not wide enough when I test it by pulling an image on to the desktop.
    My ultimate goal is drag them, sized and ready to go, and drop them onto a web browser upload page. I don't want to fumble with the extra steps of exporting them to another folder on the desktop and then upload the images from that folder to the browser.
    So does anybody know how or if it's possible to control the drag and drop SIZE /DIMENSION of an image?

    The drag and drop size is determined by your preview settings. What actually gets "dragged & dropped" is the preview, not the master file. You can control the quality and size of the preview in the Aperture preferences.

  • Drag and drop icons

    hello world....
    in the process of learning i'm trying to create a small java app that resizes and processes graphics, (using imagemagick api).
    what i'd like to be able to do is drag the icon (or shortcut) to my java app and then have the app process that, just as a windows app would do. in fact all i need really is the location of the file the user has dragged and dropped onto my app, although it would be nice if i could indicate somewhere that the file was being processed!
    i understand the use of the drag and drop re the text within java, but how do i go about dragging an external icon over a java app and having that pass me the file location (which is actually all i need...)
    thanks in advance!

    i understand the use of the drag and drop re the text
    within java, Are you sure?
    Read this:
    http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html

Maybe you are looking for

  • How do I remove an old iPod device from my list of 5 so I can add my new iMac to my iTunes account?

    I see that iTunes will only sync 5 devices to my iTunes account. One of my 5 is an old iPod that has not worked for years. How do I delete it so I can add my new iMac to my iTunes account?

  • Help with touchpad issue!!

    After looking on the web, I realise this is not an isolated issue and many people have had it. *Problem in bold if you cant be bothered reading everything :)* The problem I have is with the touchpad on my Macbook Pro. This morning my mac had a funny

  • Layout For Checks in Document Printing

    Hello The output for Checks under Bankng-Document Printing-Checks for Payment is totally different from any of the layouts listed under Banking-Outgoing Payments-Checks For Payment.. How can I see the list or have access to what is used and change to

  • Scheduling sender JDBC adater

    Hi All, I'm working on XI 7.0 . I have configured file and JMS adapter scheduling . But I have a doubt whether we can <u>schedule Sender JDBC adapter</u> to poll daily on specified time. Thanks, venu

  • Bloom filter from FCS 2 in FCS 1

    Hi, The show I'm working on is using FCP 5.1.4 and we need to use the Bloom filter provided in Final Cut Studio 2 (which we had used in the previous season of the show). I'm just wondering if anyone knows a way to get the Bloom filter into FCP 5.1.4.