Recommend me a good drag and drop tutorial

I need to make a movie whereby the user drags four items onto 4 targets and achieves a result as each object lands on the target, such as a sound. and then a well done statement at the end.
Can anyone recommend me a place where I can download such a file so I can manipulate it? I figured an hour ago when i sat at my computer that I would find one easily, but I'm really stuck now. can anyone suggest a tutorial/ site where I could get a free download of an advanced drag and drop like this?
I'd really appreciate your help!
Thanks.
Niamh.

These are the 2 good tutorials that helped me in making Drag and Drop in flash : http://www.flashvalley.com/fv_tutorials/advanced_drag_and_drop_in_Flash/
http://www.actionscript.org/resources/articles/26/1/Drag-n-Drop-and-Drop-Targets/Page1.htm l
Thanks,
Sudheendra

Similar Messages

  • Drag and Drop Tutorial  -- Most Requested

    Tutorial for one of the most reqeusted questions made! how to make drag and drop in Adobe Edge Animate , Check it out : http://www.edgehero.com/tutorials/draganddrop

    [url http://java.sun.com/docs/books/tutorial/uiswing/dnd/intro.html]Introduction to Drag and Drop

  • Sharepoint (email drag and drop)

    I would be grateful if someone could recommend a good drag and drop email program - we have just tested OnePlaceMail but this does not allow us to copy duplicate emails.  Any suggestions/recommendations gratefully received.

    We are able to
    drag files and folders into SharePoint from file share using a third party tool called PageLight.  It also allowed our end users to
    Save Outlook emails to SharePoint with Metadata
    Duplicate emails could be handled with ease including the file name management and meta data processing

  • Drag and Drop Between two Panels

    Hi,
    I am working with Swings,i created two Panels A and B. I kept some GIF or Image in Panel A,i would like to drag the gif object in to Panel B.
    when i try like this,my mouse could not communicate with two panels A and B.mouse events working Individualey,i mean mouse events working in same panel.
    Plz let me know how to communicate with two different panels with mouse. Drag and Drop between Panel A and Panel B.
    Thanking you
    MyProblems

    You might check out the Drag and Drop tutorial, especially the section Data Transfer with a Custom Component.
    Here's another approach using an overlayed non–opaque JPanel as a transfer device. The image label is transfered to the (fake) glass pane and dragged. On mouse release it is added to the JPanel below. Although I didn't build in any boundry–checking it would be a useful thing. Mostly to ensure a suitable drop target and component location in it.
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import java.net.*;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    import javax.swing.event.*;
    public class DraggingTest
        public static void main(String[] args)
            LeftPanel left = new LeftPanel();
            JPanel right = new JPanel();
            right.setBackground(new Color(200,240,220));
            right.setLayout(null);
            JPanel panel = new JPanel(new GridBagLayout());
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.weightx = 1.0;
            gbc.weighty = 1.0;
            gbc.fill = gbc.BOTH;
            panel.add(left, gbc);
            panel.add(right, gbc);
            JPanel glassPanel = new JPanel();
            glassPanel.setOpaque(false);
            JPanel overlay = new JPanel();
            OverlayLayout layout = new OverlayLayout(overlay);
            overlay.setLayout(layout);
            overlay.add(glassPanel);
            overlay.add(panel);
            ImageMover mover = new ImageMover(left, right, glassPanel);
            glassPanel.addMouseListener(mover);
            glassPanel.addMouseMotionListener(mover);
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(overlay);
            f.setSize(400,400);
            f.setLocation(600,325);
            f.setVisible(true);
    class LeftPanel extends JPanel
        Image image;
        JLabel label;
        public LeftPanel()
            loadImage();
            setBackground(Color.white);
            setLayout(null);
            label = new JLabel(new ImageIcon(image));
            label.setName("imageLabel");
            Dimension d = label.getPreferredSize();
            label.setBounds(40, 40, d.width, d.height);
            add(label);
        private void loadImage()
            String fileName = "images/dukeWaveRed.gif";
            try
                URL url = getClass().getResource(fileName);
                image = ImageIO.read(url);
            catch(MalformedURLException mue)
                System.out.println(mue.getMessage());
            catch(IOException ioe)
                System.out.println(ioe.getMessage());
    class ImageMover extends MouseInputAdapter
        LeftPanel left;
        JPanel right, glassPanel;
        JPanel activePanel;
        Component selectedComponent;  // imageLabel
        Point offset;
        boolean dragging, selected;
        public ImageMover(LeftPanel lp, JPanel p, JPanel gp)
            left = lp;
            right = p;
            glassPanel = gp;
            offset = new Point();
            dragging = false;
            selected = false;
        public void mousePressed(MouseEvent e)
            Point p = e.getPoint();
            // which panel is the mouse over
            if(!setActivePanel(p));
                return;
            // get reference to imageLabel or return
            selectedComponent = getImageLabel();
            if(selectedComponent == null)
                return;
            Rectangle labelR = selectedComponent.getBounds();
            Rectangle panelR = activePanel.getBounds();
            if(labelR.contains(p.x - panelR.x, p.y))
                activePanel.remove(selectedComponent);
                selected = true;
                glassPanel.add(selectedComponent);
                offset.x = p.x - labelR.x - panelR.x;
                offset.y = p.y - labelR.y - panelR.y;
                dragging = true;
        public void mouseReleased(MouseEvent e)
            Point p = e.getPoint();
            if(!contains(glassPanel, selectedComponent))
                return;
            glassPanel.remove(selectedComponent);
            setActivePanel(p);
            activePanel.add(selectedComponent);
            Rectangle r = activePanel.getBounds();
            int x = p.x - offset.x - r.x;
            int y = p.y - offset.y;
            Dimension d = selectedComponent.getSize();
            selectedComponent.setBounds(x, y, d.width, d.height);
            glassPanel.repaint();
            activePanel.repaint();
            dragging = false;
        public void mouseDragged(MouseEvent e)
            if(dragging)
                Point p = e.getPoint();
                int x = p.x - offset.x;
                int y = p.y - offset.y;
                Dimension d = selectedComponent.getSize();
                selectedComponent.setBounds(x, y, d.width, d.height);
                if(!selected)
                    activePanel.repaint();
                    selected = false;
                glassPanel.repaint();
        private boolean contains(JPanel p, Component comp)
            Component[] c = p.getComponents();
            for(int j = 0; j < c.length; j++)
                if(c[j] == comp)
                    return true;
            return false;
        private boolean setActivePanel(Point p)
            activePanel = null;
            Rectangle r = left.getBounds();
            if(r.contains(p))
                activePanel = left;
            r = right.getBounds();
            if(r.contains(p))
               activePanel = right;
            if(activePanel != null)
                return true;
            return false;
        private Component getImageLabel()
            Component[] c = activePanel.getComponents();
            for(int j = 0; j < c.length; j++)
                if(c[j].getName().equals("imageLabel"))
                    return c[j];
            return null;
    }

  • Drag and drop data from Numeric Control or Numeric Array to excel file

    I have two inquirries about drag and drop:
    1. How to drag and drop data from a Numeric Array or Numeric control to excel file
    2. How to drag and drop data from a Numeric Array or Numeric control to an Numeric array Indicator?
    The item 2, I tried it with the event structure, but it didnt work.
    Please do reply.
    mytestautomation.com
    ...unleashed the power, explore and share ideas on power supply testing
    nissanskyline.org
    ...your alternative nissan skyline information site

    There are very good drag and drop examples that ship with LabVIEW.  Have you looked these over to see if they can be modified for your needs?
    Matthew Fitzsimons
    Certified LabVIEW Architect
    LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison

  • Drag and Drop image is Duplicated

    Hi,
    In my code, I want to drag and drop an image from a list populated from a folder, and its information is populated from an xml file. Now, I can drag the image from the list and drop it in the container, However, when now, I want to drag around the dropped image, it is duplicated, an extra image is created in the canvas. So, if anyone can tell me how not to create an extra copy of the image in the new container (canvas) that it was dragged to.
    Here is the code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical"
    name="Drag and Drop Tutorial"
    creationComplete="init()"
    initialize="pictureService.send()">
    <mx:Script>
    <![CDATA[
    import mx.controls.Image;
    import mx.core.DragSource;
        import mx.core.IUIComponent;
        import mx.managers.DragManager;
        import mx.events.DragEvent;
        import mx.controls.Alert;
        import mx.rpc.events.FaultEvent;
    import mx.rpc.events.ResultEvent;
    import mx.collections.ArrayCollection;
    [Bindable] private var pictureData:ArrayCollection;
                private function resultHandler(event:ResultEvent):void{
                pictureData = event.result.data.image;
                private function faultHandler(event:FaultEvent):void{
                //code
    public function init():void
                // a mouseDown event will start the drag
          list.dataProvider = pictureData;
          //picture in the list is being dragged
           this.picture.addEventListener( MouseEvent.MOUSE_DOWN, beginDrag );
         // accepting a drag/drop operation...
           this.area.addEventListener( DragEvent.DRAG_ENTER, acceptDrop );
           // handling the drop...
          this.area.addEventListener( DragEvent.DRAG_DROP, handleDrop );
             public function beginDrag( mouseEvent:MouseEvent ):void
          // the drag initiator is the object being dragged (target of the mouse event)
           var dragInitiator:IUIComponent = mouseEvent.currentTarget as IUIComponent;
           // the drag source contains data about what's being dragged
           var dragSource:DragSource = new DragSource();
           // Add the data to the object.
                   dragSource.addData(1, 'value');
                    // Create a copy of the coin image to use as a drag proxy.
                    var dragProxy:Image = new Image();
                    dragProxy.source = mouseEvent.currentTarget.source;
                    dragProxy.setActualSize(mouseEvent.currentTarget.width,mouseEvent.currentTarget.height)
         // ask the DragManger to begin the drag
         DragManager.doDrag( dragInitiator, dragSource, mouseEvent, dragProxy ); 
    public function acceptDrop( dragEvent:DragEvent ):void
           var dropTarget:IUIComponent = dragEvent.currentTarget as IUIComponent;   
          // accept the drop
       DragManager.acceptDragDrop( dropTarget );
      // show feedback
            DragManager.showFeedback( DragManager.COPY );       
         public function handleDrop( dragEvent:DragEvent ):void
          var dragInitiator:IUIComponent = dragEvent.dragInitiator;
          var dropTarget:IUIComponent = dragEvent.currentTarget as IUIComponent;
            if(dragEvent.dragSource.hasFormat("items"))
              var items:Array = dragEvent.dragSource.dataForFormat("items") as Array;
            var img:Image = new Image();
            img.x=dragEvent.localX;
            img.y=dragEvent.localY;
            img.width = 50;
            img.height=50;
            img.source="assets/" + items[0].id + ".jpg";
            img.addEventListener(MouseEvent.MOUSE_MOVE,beginDrag);
            area.addChild(img);
       else
       dragEvent.dragInitiator.x=dragEvent.localX
       dragEvent.dragInitiator.y=dragEvent.localY
    ]]>
    </mx:Script>
       <mx:HTTPService id="pictureService"
    url="data/data.xml"
    result="resultHandler(event)"
    fault="faultHandler(event)"/>
    <mx:DataGrid id="list" width="238" height="200" y="26" x="10" labelField="src" dragEnabled="true"
    dataProvider="{pictureData}">
      <mx:columns>
      <mx:DataGridColumn dataField="id" id="code">
      </mx:DataGridColumn>
      <mx:DataGridColumn id="picture" draggable="true" >
      <mx:itemRenderer>
      <mx:Component>
      <mx:Image source="assets/{data.id}.jpg"  />  
      </mx:Component>
      </mx:itemRenderer>
      </mx:DataGridColumn>
    </mx:columns>
    </mx:DataGrid>
    <mx:Canvas id="area" x="266" y="28" width="436" height="401" backgroundColor="#c0c0c0"
    dragDrop="handleDrop(event)" >
    </mx:Canvas>
    </mx:Application>

    your handleDrop is called twice. you have assigned this eventlistener twice - one in init function and one in inline.
    remove one and it works.

  • Drag and Drop box?

    Hi all
    I want to code a Java application, that when executed, will display a box in a window. I then want to be able to drag a file from windows explorer into this box, and after dropping it in the box, I want the file name to be displayed in the console window. I'm really just interested in doing the drag and drop feature.
    Can anyone give me some links or some info that would help me do this?
    Thanks very much for any help!

    Did you try the Drag and Drop tutorial, http://java.sun.com/docs/books/tutorial/uiswing/dnd/intro.html? The section titled "Importing a New Flavor: Files" may be what you're looking for.

  • How to display xy coordintes of drag and drop movie

    can someone tell me how to display the coordinates of the red
    cirle shown in the drag and drop tutorial found here:
    http://www.flashvalley.com/fv_tutorials/advanced_drag_and_drop_in_Flash/
    I have done this tutorial just fine but dont know how to
    display its x and y coordinatetes in a dynamic text box as i move
    the red circle around the screen.
    thank you for any assistance you may give.
    steve

    Hi kglad,
    I dont suppose you could show me how to create the loop? My
    own research seems to indicate the onEnterFrame method would be
    easiest.
    I am just a beginner and even this is still beyond me.
    thanks

  • Create a drag and drop target set

    Hi,
    I want to be able to create the following if possible:
    Create five words that make up a sentence and they are mixed up in order. So basically I would turn each word into a Movie clip perhaps.
    I would then like to assign a target hotspot for each word so that a user can drag the words into the correct order.
    Once they are in the correct order they click a button to go to a correct response or incorrect response. Is this possible?

    Yes, it is possible.  Try seaching Google for a tutorial using terms like "AS3 drag and drop tutorial" and/or "AS3 dropTarget tutorial"

  • Tutorial: Flex Drag and Drop

    I have just published a tutorial on Drag-and-Drop in Flex:
    http://www.flexafterdark.com/tutorials/Flex-Drag-and-Drop
    I hope it is helpful and would certainly appreciate any feedback you are willing to share.
    Thank you.
    Ben Edwards

    Ben, I have a Drag & Drop related question. Please see:
    http://forums.adobe.com/thread/534259?tstart=0
    Thanks.

  • Drag and Drop an image

    Can anyone recommend me a good tutorial on how to drag and drop or even resize an image in a panel ?

    I'm back.
    I wrote a 2 classes appli that allow to move and resize images displayed in a panel.
    The first class is the most interesting one. It describes an object which extends Rectangle and manage an Image. This class names TransformableImage extends Rectangle because we need to know the bounds of the rectangle, where the image is contained in, to allow mouse interactions through the panel.
    The behavior we want is to change the kind of cursors according to the position of the mouse on the panel :
    if the mouse is out of any images the cursor is the default one. If the cursor is on an image, it can be a move cursor in the center of the image or one of the resize cursors if the mouse is on the border of the image.
    Here is the class :
    import java.awt.*;
    import javax.swing.*;
    import java.awt.image.*;
    public final class TransformableImage extends Rectangle {
         public static final int MOVE = 0;
         public static final int RESIZE_TOP = 10;
         public static final int RESIZE_BOTTOM = 20;
         public static final int RESIZE_RIGHT = 1;
         public static final int RESIZE_LEFT = 2;
         public static final int RESIZE_TOP_RIGHT_CORNER = 11;
         public static final int RESIZE_TOP_LEFT_CORNER = 12;
         public static final int RESIZE_BOTTOM_RIGHT_CORNER = 21;
         public static final int RESIZE_BOTTOM_LEFT_CORNER = 22;
         public static final int BORDER_THICKNESS = 5;
         public static final int MIN_THICKNESS = BORDER_THICKNESS*2;
         private static final Color borderColor = Color.black;
         private Image image;
         * Create an TransformableImage from the image file filename.
         * The TransformableImage bounds (inherited from the class Rectangle) are setted to the corresponding values.
         public TransformableImage(String filename) {
              ImageIcon ic = new ImageIcon(filename);
              image = ic.getImage();
              setBounds(0,0,ic.getIconWidth(), ic.getIconHeight());
         * Draw the image rescaled to fit the bounds.
         * A black rectangle is drawn around the image.
         public final void draw(Graphics2D g, ImageObserver observer) {
              Color oldColor = g.getColor();
              g.setColor(borderColor);
              g.drawImage(image, x, y, width, height, observer);
              g.draw(this);
              g.setColor(oldColor);
         * Return an int corresponding to the transformation available according to the mouse location on the image.
         * If the point p is in the border, with a thickness of BORDER_THICKNESS, around the image, the corresponding
         * transformation is returned (RESIZE_TOP, ..., RESIZE_BOTTOM_LEFT_CORNER).
         * If the point p is located in the center of the image (i.e. out of the border), the MOVE transformation is returned.
         * We allways suppose that p is contained in the image bounds.
         public final int getTransformation(Point p) {
              int px = p.x;
              int py = p.y;
              int transformation = 0;
              if (py<(y+BORDER_THICKNESS)) {
                   transformation += RESIZE_TOP;
              else
              if (py>(y+height-BORDER_THICKNESS-1)) {
                   transformation += RESIZE_BOTTOM;
              if (px<(x+BORDER_THICKNESS)) {
                   transformation += RESIZE_LEFT;
              else
              if (px>(x+width-BORDER_THICKNESS-1)) {
                   transformation += RESIZE_RIGHT;
              return(transformation);
         * Move the left side of the image, verifying that the width is > to the MIN_THICKNESS.
         public final void moveX1(int px) {
              int x1 = x+width;
              if (px>x1-MIN_THICKNESS) {
                   x = x1-MIN_THICKNESS;
                   width = MIN_THICKNESS;
              else {
                   width += (x-px);
                   x = px;               
         * Move the right side of the image, verifying that the width is > to the MIN_THICKNESS.
         public final void moveX2(int px) {
              width = px-x;
              if (width<MIN_THICKNESS) {
                   width = MIN_THICKNESS;
         * Move the top side of the image, verifying that the height is > to the MIN_THICKNESS.
         public final void moveY1(int py) {
              int y1 = y+height;
              if (py>y1-MIN_THICKNESS) {
                   y = y1-MIN_THICKNESS;
                   height = MIN_THICKNESS;
              else {
                   height += (y-py);
                   y = py;               
         * Move the bottom side of the image, verifying that the height is > to the MIN_THICKNESS.
         public final void moveY2(int py) {
              height = py-y;
              if (height<MIN_THICKNESS) {
                   height = MIN_THICKNESS;
         * Apply a given transformation with the given Point to the image.
         * The shift values dx and dy are needed for move tho locate the image at the same relative position from the cursor (p).
         public final void transform(Point p, int transformationType, int dx, int dy) {
              int px = p.x;
              int py = p.y;
              switch (transformationType) {
                   case MOVE : x = px-dx; y = py-dy;
                        break;
                   case RESIZE_TOP : moveY1(py);
                        break;
                   case RESIZE_BOTTOM : moveY2(py);
                        break;
                   case RESIZE_LEFT : moveX1(px);
                        break;
                   case RESIZE_RIGHT : moveX2(px);
                        break;
                   case RESIZE_TOP_LEFT_CORNER : moveX1(px);moveY1(py);
                        break;
                   case RESIZE_TOP_RIGHT_CORNER : moveX2(px);moveY1(py);
                        break;
                   case RESIZE_BOTTOM_LEFT_CORNER : moveX1(px);moveY2(py);
                        break;
                   case RESIZE_BOTTOM_RIGHT_CORNER : moveX2(px);moveY2(py);
                        break;
                   default :
    }And now, we need to create the panel where we are going to draw the images and interact with them with the mouse. In fact we need a paintComponent method used to draw the images and a Mouse(Motion)Listener to manage the required mouse events.
    We also have to create a method to set the convenient cursor according to tha position of the mouse over the images.
    Here is the class :
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class ImagePanel extends JComponent {
         private static final Cursor DEFAULT_CURSOR = new Cursor(Cursor.DEFAULT_CURSOR);
         private static final Cursor MOVE_CURSOR = new Cursor(Cursor.MOVE_CURSOR);
         private static final Cursor VERTICAL_RESIZE_CURSOR = new Cursor(Cursor.N_RESIZE_CURSOR);
         private static final Cursor HORIZONTAL_RESIZE_CURSOR = new Cursor(Cursor.W_RESIZE_CURSOR);
         private static final Cursor NW_SE_RESIZE_CURSOR = new Cursor(Cursor.NW_RESIZE_CURSOR);
         private static final Cursor NE_SW_RESIZE_CURSOR = new Cursor(Cursor.NE_RESIZE_CURSOR);
         public Vector images;
         * Create an ImagePanel with two images in.
         * A MouseHandler instance is added as mouse listener and mouse motion listener.
         public ImagePanel() {
              images = new Vector();
              images.add(new TransformableImage("image1.gif"));
              images.add(new TransformableImage("image2.gif"));
              setPreferredSize(new Dimension(600,600));
              MouseHandler mh = new MouseHandler();
              addMouseListener(mh);
              addMouseMotionListener(mh);
         * Simply paint all the images contained in the Vector images, calling their method draw(Graphics2D, ImageObserver).
         public void paintComponent(Graphics g) {
              Graphics2D g2D = (Graphics2D)g;
              for (int i = images.size()-1; i>=0; i--) {     
                   ((TransformableImage)images.get(i)).draw(g2D, this);
         * Inner class defining the behavior of the mouse.
         final class MouseHandler extends MouseInputAdapter {
              private TransformableImage draggedImage;
              private int transformation;
              private int dx, dy;
              public void mouseMoved(MouseEvent e) {
                   Point p = e.getPoint();
                   TransformableImage image = getImageAt(p);
                   if (image != null) {
                        transformation = image.getTransformation(p);
                        setConvenientCursor(transformation);
                   else {
                        setConvenientCursor(-1);
              public void mousePressed(MouseEvent e) {
                   Point p = e.getPoint();
                   draggedImage = getImageAt(p);
                   if (draggedImage!=null) {
                        dx = p.x-draggedImage.x;
                        dy = p.y-draggedImage.y;
              public void mouseDragged(MouseEvent e) {
                   if (draggedImage==null) {
                        return;
                   Point p = e.getPoint();
                   repaint(draggedImage.x,draggedImage.y,draggedImage.width+1,draggedImage.height+1);
                   draggedImage.transform(p, transformation,dx,dy);
                   repaint(draggedImage.x,draggedImage.y,draggedImage.width+1,draggedImage.height+1);
              public void mouseReleased(MouseEvent e) {
                   Point p = e.getPoint();
                   draggedImage = null;
         * Utility method used to get the image located at a Point p.
         * Returns null if there is no image at this point.
         private final TransformableImage getImageAt(Point p) {
              TransformableImage image = null;
              for (int i = 0, n = images.size(); i<n; i++) {     
                   image = (TransformableImage)images.get(i);
                   if (image.contains(p)) {
                        return(image);
              return(null);
         * Sets the convenient cursor according the the transformation (i.e. the position of the mouse over the image).
         private final void setConvenientCursor(int transfo) {
              Cursor currentCursor = getCursor();
              Cursor newCursor = null;
              switch (transfo) {
                   case TransformableImage.MOVE : newCursor = MOVE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_TOP : newCursor = VERTICAL_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_BOTTOM : newCursor = VERTICAL_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_LEFT : newCursor = HORIZONTAL_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_RIGHT : newCursor = HORIZONTAL_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_TOP_LEFT_CORNER : newCursor = NW_SE_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_TOP_RIGHT_CORNER : newCursor = NE_SW_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_BOTTOM_LEFT_CORNER : newCursor = NE_SW_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_BOTTOM_RIGHT_CORNER : newCursor = NW_SE_RESIZE_CURSOR;
                        break;
                   default : newCursor = DEFAULT_CURSOR;
              if (newCursor != null && currentCursor != newCursor) {
                   setCursor(newCursor);
         public static void main(String[] args) {
              JFrame frame = new JFrame("Test transformable images");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.getContentPane().add(new ImagePanel(), BorderLayout.CENTER);
              frame.pack();
              frame.setVisible(true);
    }If you want more information tell me.
    ------- Here is the unformatted version -----
    import java.awt.*;
    import javax.swing.*;
    import java.awt.image.*;
    public final class TransformableImage extends Rectangle {
         public static final int MOVE = 0;
         public static final int RESIZE_TOP = 10;
         public static final int RESIZE_BOTTOM = 20;
         public static final int RESIZE_RIGHT = 1;
         public static final int RESIZE_LEFT = 2;
         public static final int RESIZE_TOP_RIGHT_CORNER = 11;
         public static final int RESIZE_TOP_LEFT_CORNER = 12;
         public static final int RESIZE_BOTTOM_RIGHT_CORNER = 21;
         public static final int RESIZE_BOTTOM_LEFT_CORNER = 22;
         public static final int BORDER_THICKNESS = 5;
         public static final int MIN_THICKNESS = BORDER_THICKNESS*2;
         private static final Color borderColor = Color.black;
         private Image image;
         * Create an TransformableImage from the image file filename.
         * The TransformableImage bounds (inherited from the class Rectangle) are setted to the corresponding values.
         public TransformableImage(String filename) {
              ImageIcon ic = new ImageIcon(filename);
              image = ic.getImage();
              setBounds(0,0,ic.getIconWidth(), ic.getIconHeight());
         * Draw the image rescaled to fit the bounds.
         * A black rectangle is drawn around the image.
         public final void draw(Graphics2D g, ImageObserver observer) {
              Color oldColor = g.getColor();
              g.setColor(borderColor);
              g.drawImage(image, x, y, width, height, observer);
              g.draw(this);
              g.setColor(oldColor);
         * Return an int corresponding to the transformation available according to the mouse location on the image.
         * If the point p is in the border, with a thickness of BORDER_THICKNESS, around the image, the corresponding
         * transformation is returned (RESIZE_TOP, ..., RESIZE_BOTTOM_LEFT_CORNER).
         * If the point p is located in the center of the image (i.e. out of the border), the MOVE transformation is returned.
         * We allways suppose that p is contained in the image bounds.
         public final int getTransformation(Point p) {
              int px = p.x;
              int py = p.y;
              int transformation = 0;
              if (py<(y+BORDER_THICKNESS)) {
                   transformation += RESIZE_TOP;
              else
              if (py>(y+height-BORDER_THICKNESS-1)) {
                   transformation += RESIZE_BOTTOM;
              if (px<(x+BORDER_THICKNESS)) {
                   transformation += RESIZE_LEFT;
              else
              if (px>(x+width-BORDER_THICKNESS-1)) {
                   transformation += RESIZE_RIGHT;
              return(transformation);
         * Move the left side of the image, verifying that the width is > to the MIN_THICKNESS.
         public final void moveX1(int px) {
              int x1 = x+width;
              if (px>x1-MIN_THICKNESS) {
                   x = x1-MIN_THICKNESS;
                   width = MIN_THICKNESS;
              else {
                   width += (x-px);
                   x = px;               
         * Move the right side of the image, verifying that the width is > to the MIN_THICKNESS.
         public final void moveX2(int px) {
              width = px-x;
              if (width<MIN_THICKNESS) {
                   width = MIN_THICKNESS;
         * Move the top side of the image, verifying that the height is > to the MIN_THICKNESS.
         public final void moveY1(int py) {
              int y1 = y+height;
              if (py>y1-MIN_THICKNESS) {
                   y = y1-MIN_THICKNESS;
                   height = MIN_THICKNESS;
              else {
                   height += (y-py);
                   y = py;               
         * Move the bottom side of the image, verifying that the height is > to the MIN_THICKNESS.
         public final void moveY2(int py) {
              height = py-y;
              if (height<MIN_THICKNESS) {
                   height = MIN_THICKNESS;
         * Apply a given transformation with the given Point to the image.
         * The shift values dx and dy are needed for move tho locate the image at the same relative position from the cursor (p).
         public final void transform(Point p, int transformationType, int dx, int dy) {
              int px = p.x;
              int py = p.y;
              switch (transformationType) {
                   case MOVE : x = px-dx; y = py-dy;
                        break;
                   case RESIZE_TOP : moveY1(py);
                        break;
                   case RESIZE_BOTTOM : moveY2(py);
                        break;
                   case RESIZE_LEFT : moveX1(px);
                        break;
                   case RESIZE_RIGHT : moveX2(px);
                        break;
                   case RESIZE_TOP_LEFT_CORNER : moveX1(px);moveY1(py);
                        break;
                   case RESIZE_TOP_RIGHT_CORNER : moveX2(px);moveY1(py);
                        break;
                   case RESIZE_BOTTOM_LEFT_CORNER : moveX1(px);moveY2(py);
                        break;
                   case RESIZE_BOTTOM_RIGHT_CORNER : moveX2(px);moveY2(py);
                        break;
                   default :
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class ImagePanel extends JComponent {
         private static final Cursor DEFAULT_CURSOR = new Cursor(Cursor.DEFAULT_CURSOR);
         private static final Cursor MOVE_CURSOR = new Cursor(Cursor.MOVE_CURSOR);
         private static final Cursor VERTICAL_RESIZE_CURSOR = new Cursor(Cursor.N_RESIZE_CURSOR);
         private static final Cursor HORIZONTAL_RESIZE_CURSOR = new Cursor(Cursor.W_RESIZE_CURSOR);
         private static final Cursor NW_SE_RESIZE_CURSOR = new Cursor(Cursor.NW_RESIZE_CURSOR);
         private static final Cursor NE_SW_RESIZE_CURSOR = new Cursor(Cursor.NE_RESIZE_CURSOR);
         public Vector images;
         * Create an ImagePanel with two images in.
         * A MouseHandler instance is added as mouse listener and mouse motion listener.
         public ImagePanel() {
              images = new Vector();
              images.add(new TransformableImage("image1.gif"));
              images.add(new TransformableImage("image2.gif"));
              setPreferredSize(new Dimension(600,600));
              MouseHandler mh = new MouseHandler();
              addMouseListener(mh);
              addMouseMotionListener(mh);
         * Simply paint all the images contained in the Vector images, calling their method draw(Graphics2D, ImageObserver).
         public void paintComponent(Graphics g) {
              Graphics2D g2D = (Graphics2D)g;
              for (int i = images.size()-1; i>=0; i--) {     
                   ((TransformableImage)images.get(i)).draw(g2D, this);
         * Inner class defining the behavior of the mouse.
         final class MouseHandler extends MouseInputAdapter {
              private TransformableImage draggedImage;
              private int transformation;
              private int dx, dy;
              public void mouseMoved(MouseEvent e) {
                   Point p = e.getPoint();
                   TransformableImage image = getImageAt(p);
                   if (image != null) {
                        transformation = image.getTransformation(p);
                        setConvenientCursor(transformation);
                   else {
                        setConvenientCursor(-1);
              public void mousePressed(MouseEvent e) {
                   Point p = e.getPoint();
                   draggedImage = getImageAt(p);
                   if (draggedImage!=null) {
                        dx = p.x-draggedImage.x;
                        dy = p.y-draggedImage.y;
              public void mouseDragged(MouseEvent e) {
                   if (draggedImage==null) {
                        return;
                   Point p = e.getPoint();
                   repaint(draggedImage.x,draggedImage.y,draggedImage.width+1,draggedImage.height+1);
                   draggedImage.transform(p, transformation,dx,dy);
                   repaint(draggedImage.x,draggedImage.y,draggedImage.width+1,draggedImage.height+1);
              public void mouseReleased(MouseEvent e) {
                   Point p = e.getPoint();
                   draggedImage = null;
         * Utility method used to get the image located at a Point p.
         * Returns null if there is no image at this point.
         private final TransformableImage getImageAt(Point p) {
              TransformableImage image = null;
              for (int i = 0, n = images.size(); i<n; i++) {     
                   image = (TransformableImage)images.get(i);
                   if (image.contains(p)) {
                        return(image);
              return(null);
         * Sets the convenient cursor according the the transformation (i.e. the position of the mouse over the image).
         private final void setConvenientCursor(int transfo) {
              Cursor currentCursor = getCursor();
              Cursor newCursor = null;
              switch (transfo) {
                   case TransformableImage.MOVE : newCursor = MOVE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_TOP : newCursor = VERTICAL_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_BOTTOM : newCursor = VERTICAL_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_LEFT : newCursor = HORIZONTAL_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_RIGHT : newCursor = HORIZONTAL_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_TOP_LEFT_CORNER : newCursor = NW_SE_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_TOP_RIGHT_CORNER : newCursor = NE_SW_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_BOTTOM_LEFT_CORNER : newCursor = NE_SW_RESIZE_CURSOR;
                        break;
                   case TransformableImage.RESIZE_BOTTOM_RIGHT_CORNER : newCursor = NW_SE_RESIZE_CURSOR;
                        break;
                   default : newCursor = DEFAULT_CURSOR;
              if (newCursor != null && currentCursor != newCursor) {
                   setCursor(newCursor);
         public static void main(String[] args) {
              JFrame frame = new JFrame("Test transformable images");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.getContentPane().add(new ImagePanel(), BorderLayout.CENTER);
              frame.pack();
              frame.setVisible(true);
    Denis

  • Drag and drop imported photos in iPhoto '09 causes duplication of old existing photos and loss if new photos

    Good Afternoon All,
    I'd be grateful for any help with the following problem.
         After importing about 30 photos from my camera into iPhoto '09 (version 8.1.2), I selected the first group of 10 and dragged and dropped them into an existing album in my iPhoto library.        I repeated this process with another  group of photos , dropping them into a different existing album. Again, I repeated this process with the last remaining photos from the original imported group of 30.
          This is exactly the same process I have used successfully on many previous occasions when adding to my iPhoto library of 6000+ photos.
           However when I later opened each of the 3 existing albums to check on the 30 new photos none of these new photos were visible.     Instead each of the three albums now contained between 5 and 15 duplicates of old photos from different and unrelated albums in addition to their normal content.       These duplicates were not present before I imported the 30 new photos.    I then opened every Album in my entire library of 6000+ photos  without finding any sign of the 30 new photos.   These 30 photos have also disappeared from "Last Import" which now shows a blank page with 0 imports.
         I still have the 30 new photos saved on my camera and could import them again. My concern is that with my very limited diagnostic skills re. my iMac OS X (10.6.8) I may aggravate the problem
    Thank you

    Morning Terence
                             Thank you for your suggestion. When I held the Option Key and opened iPhoto the resulting menu showed 2 libraries , "iPhoto Library" and "iPhoto Library (default )". 
         I then recalled that 12 months ago I had created this duplicate library when attempting to recover some lost photos.    On opening each of these two libraries in turn, I notice that they are not identical.  Rather than create another new library, I imported some new photos into "iPhoto Library "  and was then able to drag and drop successfully into this library.    When I tried to do the same with "iPhoto Library (default )"  all the problems originally described re-occured.
         Having found the problem is in the Default library I would now like to move some photos from it into "iPhoto Library" and then remove the Default Library.
         Could you recommend how best to do this or is it not a good idea?
    Regards.....Gilvin

  • Drag and Drop to Change Order in a List

    Does anyone know of an example where there is the ability to drag and drop elements in a list and thus change their order? (I.E. drag item one below item two and then item one and two change locations)
    Thanks!

    Check out http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html
    There's an example towards the end of the page for drag-and-drop between 2 JLists. Might be a good starting point.

  • Drag and Dropping Photographs to the desktop

    We're running on a new MacBook, with leopard. - Running 7.1.1 (2008) iPhoto.
    As we've always done in the past, we are able to drag individual or groups of selected photographs directly from iPhoto onto the desktop.
    We've recently uploaded some new photographs into iPhoto 08, using the same camera we've had for years....
    Our older photographs (1month +) are still able to be dropped onto the desktop, for use in other applications, such as photoshop.
    However all of our new photographs WONT. When dragging the older photographs we receive an icon showing number of photographs and a green PLUS (ie, it copies the file, rather than moving it)\
    When doing this with the newer photographs - we get a little NO ENTRY icon, and when letting go after the drag nothing happens.
    We are able to export the photographs from the file menu, however, this is quite a slow process, and we would like to be able to export just by dragging and dropping.
    If anyone could point us in the right direction of a solution, it would be much appreciated.
    Dan

    Daniel:
    What happens when you bring up one of those problem photos in the edit window? Do you see it or some blank window, either white or gray? You can try the following:
    Run iRepair on your iPhoto LIbrary package as follows:
    1 - download iRepair and launch.
    2 - click on the lock and enter your admin password
    3 - click on the Select button and navigate to and select the iPhoto library.
    5 - set the owner to your short admin name with read, write and execute privileges.
    6 - set group to staff or the current group with read, write and execute privileges
    7 - set others to read only
    6 - click on the Apply button.
    See if that will help.
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've created an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries and Leopard. iPhoto does not have to be closed to run the application, just idle. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • Old Drag and Drop With Toast Issue:

    I found this link to an old discussion, but it does not resolve my issue:
    http://discussions.apple.com/message.jspa?messageID=9282890#9282890
    I burnt two nice LightScribe labels, (nice because I cooked 'em twice for extra darkness, which takes time,) and then, after assuming that if I dragged and dropped my iTunes files to the desk top and then to Toast, as the above thread recommended, that since the files were accepted by toast doing things that way, that things were back to normal. I finished two beautiful CD's (I had a lot of work into the design of the labels,) by burning the music on to the disks. Well, my car cd player wouldn't play them, that is not normal, and I have two beautifully useless CD's which were the product of a lot of time and labor not to mention the cost of the disks... I've always been able to play back using the old process, (without the desktop drag and drop step,) - I'm running an iTunes version way beyond when this bug was supposed to be fixed. What do I do? How do I get back to being able to go directly from iTunes to Toast with successful playback? Thanks for your help with this!
    Message was edited by: probassist

    To anselmo Stiffan:
    Which problem did you solve: the double click with one tap or three finger drag? I too have aluminum 2008 MacBook, and I found the preferences and accessibility section but seem to fail in finding the right combo of preferences I'm used to or like. Ok, so the three finger drag is good, but click or tab... drives me bonkers!!! Everything was fine for me even after updating to Mountin Lion back in July 2012, but then all of a sudden in October 'my trackpad doesn't work the same. I don't even want to get on the computer anymore, because I'm annoyed and I cannot click on my user account to login with plugging in a mouse or using keyboard shortcut functions. It's hit or miss with my trackpad working, it freezes after awhile, then I have to plug in the darn mouse. I checked my trackpad firmware, it said up to date....I may have to actually start a new discussion??? But to continue venting... Some menu's need one tap, some require double tap... I cannot use one click unless its set to left or right for alternate menu's. Its just bad in my carpel tunnel and frustrating... I've been searching discussions for similar issues and I saw this. I saw you had an older Mac? It's funny how I switched over 4 years to Mac and mine is almost obsolete? I'm afraid to take it in only to pay more money. I guess my real question besides double clicking option would be if other folks with "the older Aluminum" 2008  MacBook models are having similar problems?

Maybe you are looking for

  • So much performance data - which are the key ones to see if DB is tuned

    There is so much metrics in SAP CCMS DB02 and DBAcockpit. WHat are some of the key metrics to look for when trying to determine if my DB is tuned properly. Some are obvious like cache hit percentage but I wonder if some one could suggest metrics to l

  • Apps disappearing

    I've had an iPhone 4 for about a year. For the past several months,  I've been having a problem with all of my apps disappearing.  Some are games but I've paid for and installed others.  They download fine and work fine but about once a week, all of

  • ¿Version de prueba Adobe CS5 Design Premium en Español?

    Hola a todos Tengo una pregunta sencilla. Ya para estas fechas han salido las versiones de prueba de los programas de la CS5 en la mayoría de idiomas, pero para la versión de la Design Premium no ha salido aún. He estado revisando y sólo aparecen par

  • Help -Can't print to my HP LaserJet via Ethernet Bridge

    I have a new MacBook Pro with OS X 10.4.5. I'm trying to print with my old HP Laserjet 4MP Postcript printer. The printer is an old serial port printer connected to an Asante Ethernet Bridge with an Ethernet cord that plugs into my computer. This has

  • Theatrical Trailers

    Since May 12 I have been unable to access several different movie trailers in the store. Not all, only a few. In fact, even one of the studios has been unavailable too. When I try to get the new Inception and Rush trailers I get the "Could not comple