How to drag and drop href image from webbrowser to office using vsto c# wpf?

I want to drag and drop href images from web browser to office using C# wpf. Is it possible to drag href images ? give me the solution

Hi,
Are you developing an Office Add-in application? Do you mean you hold a wpf Web Browser control in the Office Add-in project?
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • Drag and drop a image from html page into flex

    how can i drag a image form the html page and drop it into
    the flex application.

    Hi,
    There's no direct support for this. But you could implement
    drag and drop the way you normally would in javascript. Except
    here, on mouseUp over a div encapsulating the object or embed tag
    (the flash object), you'll need to make a call into actionscript
    from javascript indicating that a drag and drop happened.
    For more info, see
    how
    to drag and drop using javascript and
    actionscript
    and javascript communication

  • How to drag and drop an Image between two JPanels inside a Split Pane

    I'm tring to do that, and my actual problem is as follows:
    I drag the Image from the bottomPanel but I can't drop it in the topPanel, I'm using this classes:
    import java.util.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import java.awt.dnd.*;
    import java.awt.datatransfer.*;
    import java.awt.image.*;
    public class MoveableComponentsContainer extends JSplitPane {     
         public DragSource dragSource;
         public DropTarget dropTarget;
    public JPanel topPanel = new JPanel();
    public JPanel bottomPanel = new JPanel();
         public int ancho;
    public int alto;
    public MoveableLabel lab1,lab2,lab3,lab4;
    public Icon ico1, ico2,ico3,ico4;
    private static BufferedImage buffImage = null; //buff image
         private static Point cursorPoint = new Point();
    public int getMaximumDividerLocation() {
    return ( ( int ) ( alto * .85 ) );
    public int getMinimumDividerLocation() {
    return( ( int ) ( alto * .85 ) );
         public MoveableComponentsContainer(int Weight, int Height ) {
    alto = Height;
    ancho = Weight;
    setOrientation( VERTICAL_SPLIT);
    setDividerSize(2);
    getMaximumDividerLocation();
    getMinimumDividerLocation();
    setPreferredSize(new Dimension( (int) ( Weight * .99 ), (int) ( Height * .94 ) ) );
    setDividerLocation( getMaximumDividerLocation() );
    System.out.println( " getDividerLocation() = " + getDividerLocation() );
    topPanel.setName("topPanel");
    bottomPanel.setName("bottomPanel");
    bottomPanel.setPreferredSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .15 ) ) );
    bottomPanel.setMaximumSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .15 ) ) );
    bottomPanel.setMinimumSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .15 ) ) );
    topPanel. setPreferredSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .85 ) ) );
    topPanel. setMaximumSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .85 ) ) );
    topPanel. setMinimumSize( new Dimension( (int) ( Weight * .99 ), (int) ( ( Height * .94 ) * .85 ) ) );
    bottomPanel.setEnabled(true);
    bottomPanel.setVisible(true);
    bottomPanel.setBackground( new Color( 57,76,123 ) );
    topPanel. setEnabled(true);
    topPanel. setVisible(true);
    topPanel. setBackground( new Color( 57,76,123 ) );
    setBottomComponent( bottomPanel );
    setTopComponent( topPanel );
    setOneTouchExpandable( false );
    bottomPanel.setBorder(BorderFactory.createTitledBorder("Drag and Drop Test"));
              setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED, Color.white, Color.gray));
    bottomPanel.setLayout( new FlowLayout() );
    topPanel.setLayout(new FlowLayout());
              addMoveableComponents();
         private void addMoveableComponents() {
    ico1 = new ImageIcon( "/usr/local/installers/java/lll/DnD/switchm.gif");
    lab1 = new MoveableLabel("Centrales", ico1, topPanel );
    lab1.setName("labelOne");
    bottomPanel.add( lab1 );
              lab2 = new MoveableLabel("Destinos", ico1, topPanel);
    lab2.setName("labelTwo");
              bottomPanel.add( lab2 );
              lab3 = new MoveableLabel("Registros", ico1, topPanel );
    lab3.setName("labelThree");
              bottomPanel.add( lab3 );
              lab4 = new MoveableLabel("Parametros", ico1, topPanel);
    lab4.setName("labelFour");
              bottomPanel.add( lab4 );
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.border.*;
    import java.awt.dnd.*;
    import java.awt.datatransfer.*;
    public class MoveableLabel extends JLabel implements Transferable {
    final static int FILE = 0;
    final static int STRING = 1;
    final static int IMAGE = 2;
    DataFlavor flavors[] = { DataFlavor.javaFileListFlavor,
    DataFlavor.stringFlavor,
    DataFlavor.imageFlavor };
    public JPanel PanelDestino;
    public JPanel PanelOrigen;
    public DropTarget dropTarget;
    public DropTargetListener dropTargetLis;
         private static final Border border = BorderFactory.createLineBorder(Color.black, 1);
         public MoveableLabel(String text, Icon ic, JPanel DestPanel) {
              super( text, ic, TRAILING);
    PanelDestino = DestPanel;
              MouseEventForwarder forwarder = new MouseEventForwarder();
              addMouseListener(forwarder);
              addMouseMotionListener(forwarder);
              setBorder(border);
              setBounds(0,0,50,100);
              setOpaque(true);
    setTransferHandler(new TransferHandler("text"));
    setBackground( new Color( 57,76,123 ) );
    public synchronized DataFlavor[] getTransferDataFlavors() {
         return flavors;
    public boolean isDataFlavorSupported(DataFlavor flavor) {
    boolean b = false;
    b |= flavor.equals(flavors[ FILE ]);
    b |= flavor.equals(flavors[STRING]);
    b |= flavor.equals(flavors[ IMAGE]);
    return (b);
    public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, java.io.IOException {
    return this;
         final class MouseEventForwarder extends MouseInputAdapter {
              public void mousePressed(MouseEvent e) {
                   Container parent = getParent();
    Container brother = (Container)PanelDestino;
    System.out.println( "Parent 1 = " + parent.getName() );
    System.out.println( "Destino 1 = " + brother.getName() );
    JComponent c = (JComponent) e.getSource();
    System.out.println( "getsource() = " + c.getName() );
    TransferHandler th = c.getTransferHandler();
    th.exportAsDrag( c, e, TransferHandler.COPY_OR_MOVE );
    dropTarget = getDropTarget();
    System.out.println( "dropTarget.getComponent().getName() = " + dropTarget.getComponent().getName() );
    for ( int a=0; a < parent.getComponentCount(); a++ ) {
    parent.getComponent( a ).setEnabled( false );
    brother.setDropTarget( dropTarget );
    System.out.println( "dropTarget.getComponent().getName() = " + dropTarget.getComponent().getName() );
              public void mouseReleased(MouseEvent e) {
                   Container parent = getParent();
    Container brother = PanelDestino;
    System.out.println( "Parent 2 = " + parent.getName() );
    System.out.println( "Destino 2 = " + PanelDestino.getName() );
    parent.setEnabled( true );
    brother.setEnabled( false );
    for ( int a=0; a < parent.getComponentCount(); a++ ) {
    parent.getComponent( a ).setEnabled( true );
    import java.awt.*;
    import javax.swing.*;
    public class TestDragComponent extends JFrame {
         public TestDragComponent() {
    super("TestDragComponent");
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension dm = new Dimension();
    dm = tk.getScreenSize();
    System.out.println(dm.height);
    System.out.println(dm.width );
    Container cntn = getContentPane();
    cntn.setFont(new Font("Helvetica", Font.PLAIN, 14));
    cntn.add(new MoveableComponentsContainer(dm.width,dm.height));
              pack();
              setVisible(true);
         public static void main(String[] args) {
              new TestDragComponent();

    Ok I found the answer to your problem. If you download the tutorial they have the code there it's in one folder. I hope this helps.
    http://java.sun.com/docs/books/tutorial/

  • How to drag and drop an email from Outlook Express (with example code)

    Hi,
    It is possible to drag a mail from Outlook Express and drop it on the desktop, and the file created is a .eml, which is a text file.
    If I drop it into a Java application, no DataFlavor is provided to make the data transfer possible.
    As the data to transfer is a text, it should be possible to drop it.
    How to make a DataFlavor available and recover the text as a stream of characters?
    Example code
    The small application below shows the MIME type of the data that is about to be dropped. If you drag an icon from the desktop, a type will be displayed; if you drag an Outlook Express mail, no type will be displayed.
    Thanks.
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.datatransfer.DataFlavor;
    import java.awt.dnd.DropTarget;
    import java.awt.dnd.DropTargetDragEvent;
    import java.awt.dnd.DropTargetDropEvent;
    import java.awt.dnd.DropTargetEvent;
    import java.awt.dnd.DropTargetListener;
    import java.util.List;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JTree;
    public class TestSDN extends JFrame {
        void run () {
            JLabel lab = new JLabel();
            lab.setPreferredSize (new Dimension (100, 100));
            lab.setOpaque(true);
            lab.setBackground(Color.RED);   
            getContentPane().add (lab);
            new DropTarget(lab, new DropTargetListener(){
                public void dragEnter(DropTargetDragEvent dtde) {
                    System.out.println("dragEnter DataFlavors="+dtde.getCurrentDataFlavors().length);
                    for (DataFlavor df: dtde.getCurrentDataFlavors())
                        System.out.println("DataFlavor MIME type="+df.getMimeType());
                public void dragExit(DropTargetEvent arg0) {
                public void dragOver(DropTargetDragEvent arg0) {
                public void drop(DropTargetDropEvent arg0) {
                public void dropActionChanged(DropTargetDragEvent arg0) {
            pack();
            setVisible (true);
        public static void main(String[] args) {
            new TestSDN().run();
    }Edited by: JavaGame on Jan 29, 2009 9:56 AM
    Edited by: JavaGame on Jan 29, 2009 9:57 AM

    It might just be Microsoft not using standards? I remember having a similar situation - I had an application that could have a zip entry fron 7-zip drag-and-dropped into it (came over as plain text, or maybe an InputStream, can't remember), but when you drill into a zip file with Windows (Vista at least), and try to drag-and-drop a zip entry from Windows Explorer, Java shows no dataflavors available. I just assumed Microsoft wasn't exporting the zip entry in any standard format (such as plain text).
    Sorry, I know that wasn't very helpful, just thought I'd share a similar experience. :)

  • How to drag and drop user from one node to other node.

    Dear All,
    How to drag and drop user from one node to other node.I tried but no success.
    What are precautions to be taken.
    Cay anybody kindly explain it.
    Thank you.

    Hello, if you had this message you had created BP....
    Now you don't have to user USERS_GEN this transaction is used only in first action, when you create the user in R/3 and then you pass this user to EBP in the organizational structure.
    Now you have to:
    1) Go to PPOMA_BBP
    2) Double click on organizational unit that you want to put this user (purchasing organization or purchasing group box for example)
    3) Select assign button in the top of the functions in the transaction
    4) Click on incorporates -- position
    5) Put userID that you want to add in this organizational unit
    6) Click Save
    Thanks
    Rosa

  • How to drag and drop from shared library to iphone/ipad?

    Since our Mac Pro has more storage, that's where I keep our iTunes videos, to avoid taking up space on my wife's laptop. Sharing the libraries works ok, except for one issue.
    When my wife wants to put movies onto her iPhone or iPad, iTunes won't let her drag and drop them directly from the shared library. She can copy them just fine to her local library and from there to the devices, but that is cumbersome and takes up disk space.
    Please don't tell me it isn't possible because we did have it working for some time, I just don't know what's changed. The devices are set to "manually manage", drag and drop works locally, just not from the share.
    Thanks!

    Take a look at this tutorial: [url http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html]How to Use Drag and Drop and Data Transfer.
    If you read it carefully and study the samples, I think you should get rid of your first question.
    Concerning the second question, you can overwrite the isCellEditable(int row, int column) method to return false. This will block any editing from the table.
    Hope this helped,
    Regards.

  • 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

  • How to drag and drop a picture at run time in a window displaying pictures?

    How to drag and drop a picture at run time in a window displaying pictures on the front panel. The main thing is that the window is displaying frames continuously?

    vivman,
    So from your description you have a picture control where you've already created an image and you'd like to drag an image around inside of the picture control. This can be done although it is going to take a significant amount of research and programming on your behalf. You can use the drag event in the event handler to find out when the drag occurs and where the cursor is. Then edit the picture as you move your mouse so that when you drop the picture gets updated.
    The even structure is a somewhat advanced topic and the drag and drop feature is one of the more advanced uses of this structure. I would search the example finder (help>>find examples) for "event" and "drag" to see how to use these events. Also you'll want to look at the examples for the picture control.
    Sounds like a cool project! Check out Darren's Weekly Nugget 10/30/2006 this topic (http://forums.ni.com/ni/board/message?board.id=170&message.id=212920). It might prove useful.
    Good luck!
    Chris C
    Chris Cilino
    National Instruments
    LabVIEW Product Marketing Manager
    Certified LabVIEW Architect

  • I just downloaded the new version of iTunes 10 and now it won't let me drag and drop any files from my computer.

    I just downloaded the new version of iTunes 10 and now it won't let me drag and drop any files from my computer into my iTunes. It lets me play the song from the folder in my computer and then it opens with iTunes and plays the song all the way through, but then if I try to play it again, it says the file cannot be located. So then I go to locate and go to the folder and all that and select it and nothing happens.

    Not sure whether for instance you initially had a Yahoo optimised version of Firefox, and have now overwritten it with an official Mozilla version. Although the Mozilla version should NOT add unwanted features, but the Yahoo version may well do.
    If you merely need to find the Yahoo emails page quickly just add it as a bookmark or as a bookmark on the Bookmarks toolbar and make sure that is visible.
    Clicking the star icon on the location bar whilst looking at your emails will bookmark the page.
    * [[How to use bookmarks to save and organize your favorite websites]]
    * [[Bookmarks Toolbar - Display your favorite websites at the top of the Firefox window]]
    I do not use Yahoo myself,and am not sure what add-ons are available. You could search yourself using
    * FirefoxButton -> add-ons
    ** see [[Find and install add-ons to add features to Firefox]]
    ** examples [https://addons.mozilla.org/en-us/firefox/addon/yahoo-toolbar/ yahoo toolbar] & [https://addons.mozilla.org/en-us/firefox/addon/yahoo-mail-notifier/ mail notifier]
    * also look at Yahoo's own information such as http://help.yahoo.com/tutorials/toolbar/cl3/c3_ff_toolbar1.html

  • How to drag and drop tab nodes between tab panes

    I'm working on example from this tutorial( Drag-and-Drop Feature in JavaFX Applications | JavaFX 2 Tutorials and Documentation ). Based on the tutorial I want to drag tabs between two tabs. So far I managed to create this code but I need some help in order to finish the code.
    Source
    tabPane = new TabPane();
    Tab tabA = new Tab();
       Label tabALabel = new Label("Main Component");
    tabPane.setOnDragDetected(new EventHandler<MouseEvent>()
                @Override
                public void handle(MouseEvent event)
                    /* drag was detected, start drag-and-drop gesture*/
                    System.out.println("onDragDetected");
                    /* allow any transfer mode */
                    Dragboard db = tabPane.startDragAndDrop(TransferMode.ANY);
                    /* put a string on dragboard */
                    ClipboardContent content = new ClipboardContent();
                    content.put(DataFormat.PLAIN_TEXT, tabPane);
                    db.setContent(content);
                    event.consume();
    What is the proper way to insert the content of the tab as object? Into the tutorial simple text is transferred. How I must modify this line content.put(DataFormat.PLAIN_TEXT, tabPane);?
    And what is the proper way to insert the tab after I drag the tab:
    Destination
    tabPane.setOnDragDropped(new EventHandler<DragEvent>()
                @Override
                public void handle(DragEvent event)
                    /* data dropped */
                    /* if there is a string data on dragboard, read it and use it */
                    Dragboard db = event.getDragboard();
                    boolean success = false;
                    if (db.hasString())
                        //tabPane.setText(db.getString());
                        Tab tabC = new Tab();
                        tabPane.getTabs().add(tabC);
                        success = true;
                    /* let the source know whether the string was successfully
                     * transferred and used */
                    event.setDropCompleted(success);
                    event.consume();
    I suppose that this transfer can be accomplished?
    Ref javafx 2 - How to drag and drop tab nodes between tab panes - Stack Overflow

    I would use a graphic (instead of text) for the Tabs and call setOnDragDetected on that graphic. That way you know which tab is being dragged. There's no nice way to put the Tab itself into the dragboard as it's not serializable (see https://javafx-jira.kenai.com/browse/RT-29082), so you probably just want to store the tab currently being dragged in a property.
    Here's a quick example; it just adds the tab to the end of the current tabs in the dropped pane. If you wanted to insert it into the nearest location to the actual drop you could probably iterate through the tabs and figure the coordinates of each tab's graphic, or something.
    import java.util.Random;
    import javafx.application.Application;
    import javafx.beans.property.ObjectProperty;
    import javafx.beans.property.SimpleObjectProperty;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.control.Tab;
    import javafx.scene.control.TabPane;
    import javafx.scene.input.ClipboardContent;
    import javafx.scene.input.DragEvent;
    import javafx.scene.input.Dragboard;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.input.TransferMode;
    import javafx.scene.layout.StackPane;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    public class DraggingTabPane extends Application {
      private static final String TAB_DRAG_KEY = "tab" ;
      private ObjectProperty<Tab> draggingTab ;
    @Override
      public void start(Stage primaryStage) {
      draggingTab = new SimpleObjectProperty<>();
      TabPane tabPane1 = createTabPane();
      TabPane tabPane2 = createTabPane();
      VBox root = new VBox(10);
      root.getChildren().addAll(tabPane1, tabPane2);
      final Random rng = new Random();
      for (int i=1; i<=8; i++) {
        final Tab tab = createTab("Tab "+i);
        final StackPane pane = new StackPane();
          int red = rng.nextInt(256);
          int green = rng.nextInt(256);
          int blue = rng.nextInt(256);
        String style = String.format("-fx-background-color: rgb(%d, %d, %d);", red, green, blue);
        pane.setStyle(style);
        final Label label = new Label("This is tab "+i);
        label.setStyle(String.format("-fx-text-fill: rgb(%d, %d, %d);", 256-red, 256-green, 256-blue));
        pane.getChildren().add(label);
        pane.setMinWidth(600);
        pane.setMinHeight(250);
        tab.setContent(pane);
        if (i<=4) {
          tabPane1.getTabs().add(tab);
        } else {
          tabPane2.getTabs().add(tab);
      primaryStage.setScene(new Scene(root, 600, 600));
      primaryStage.show();
      public static void main(String[] args) {
      launch(args);
      private TabPane createTabPane() {
        final TabPane tabPane = new TabPane();
        tabPane.setOnDragOver(new EventHandler<DragEvent>() {
          @Override
          public void handle(DragEvent event) {
            final Dragboard dragboard = event.getDragboard();
            if (dragboard.hasString()
                && TAB_DRAG_KEY.equals(dragboard.getString())
                && draggingTab.get() != null
                && draggingTab.get().getTabPane() != tabPane) {
              event.acceptTransferModes(TransferMode.MOVE);
              event.consume();
        tabPane.setOnDragDropped(new EventHandler<DragEvent>() {
          @Override
          public void handle(DragEvent event) {
            final Dragboard dragboard = event.getDragboard();
            if (dragboard.hasString()
                && TAB_DRAG_KEY.equals(dragboard.getString())
                && draggingTab.get() != null
                && draggingTab.get().getTabPane() != tabPane) {
              final Tab tab = draggingTab.get();
              tab.getTabPane().getTabs().remove(tab);
              tabPane.getTabs().add(tab);
              event.setDropCompleted(true);
              draggingTab.set(null);
              event.consume();
        return tabPane ;
      private Tab createTab(String text) {
        final Tab tab = new Tab();
        final Label label = new Label(text);
        tab.setGraphic(label);
        label.setOnDragDetected(new EventHandler<MouseEvent>() {
          @Override
          public void handle(MouseEvent event) {
            Dragboard dragboard = label.startDragAndDrop(TransferMode.MOVE);
            ClipboardContent clipboardContent = new ClipboardContent();
            clipboardContent.putString(TAB_DRAG_KEY);
            dragboard.setContent(clipboardContent);
            draggingTab.set(tab);
            event.consume();
        return tab ;

  • When i drag and drop an image on my site. it gives the following error. "Unable to access local files due to browser security settings. To overcome this, follo"

    I am using the firefox version 17 and when i drag and drop an image on my website. It gives me the following error.
    Unable to access local files due to browser security settings. To overcome this, follow these steps: (1) Enter "about:config" in the URL field; (2) Right click and select New->Boolean; (3) Enter "signed.applets.codebase_principal_support" (without the quotes) as a new preference name; (4) Click OK and try loading the file again. Or go to the homepage for a link to the tutorial on how to do it.
    I have completed the above steps and it is still showing the same error message. Any help would be highly appreciated.
    Thanks.

    Thanks kumars ,
    I have a specific drag and drop area on our website. This works fine for all earlier releases of Firefox after these security settings
    "(1) Enter "about:config" in the URL field; (2) Right click and select New->Boolean; (3) Enter "signed.applets.codebase_principal_support" (without the quotes) as a new preference name; (4) Click OK and try loading the file again."
    Bust these settings not work for me in Firefox 17.
    Yes the drag and drop functionality is java script based and i am not using any script blocker addons.

  • How to Drag and Drop in between Stacks?

    I have a folder with various stacks and single images that I would like to sort manually. It seems impossible to drag and drop an image in between two stacks. It always ends up stacked with one or the other. I am being very careful to be sure that neither stack shows a border around it or is lighter than the other. But it makes no difference. Even if I expand both stacks, I can't drop an image in between. I have to completely UNSTACK the images, drag and then RE-STACK. Am I missing something??(running LR 2.4 on OSX 10.5.8)

    Yeah, it's a bit tricky, messing with stacks and drag-and-drop.
    Try going the other way round: drag and drop your stack (by selecting all images of the stack) instead of your single image, sometimes it helps (depending on the situation). The Remove from Stack command also helps to extract a single image from a stack without breaking and re-stacking.

  • BUG - Drag and drop an image, only working at the 2nd try

    I use the last version of JDeveloper : 11g R1 : 11.1.1.2.0
    I try to drag and drop an image in a facet of a panelsplitter.
    Once the page is loaded, the first time I try to drag the image, it does not work : the image does not follow the mouse.
    When I try to drag the image again, then it works : the image follow the mouse
    So I don't think it's related to the destination/target.
    I feel it's so simple, since it just requires to add <af:componentDragSource/> inside <af:image/>
    that if it does not work, it can only be a bug in the functionality offered by ADF ...
    Or maybe there is something wrong with the generation of the page ?
    I get this message in blue in the "running log of WebLogic" :
    <FormRenderer><setupEncodingContext> Multiple forms detected on viewId: /myPage.jspx. Rich client currently has some limitations in dealing with multiple forms.
    Please note that I use jsp:include inside f:subview to include fragments (.jsff) so that the source and the destination are not in the same file, the source in a .jsff while the destination is on the main .jspx
    The code related to the drag and drop :
    <af:form id="form">
    <af:panelSplitter orientation="vertical" splitterPosition="70" id="psHeader" clientComponent="true">
    <af:panelAccordion id="paPref" discloseNone="true" styleClass="fullSize">
    <af:showDetailItem id="sdiTemp" text="Templates">
    <af:panelBox>
    <af:panelGroupLayout id="pglTemp" layout="scroll">
    <af:panelList id="plTemp" rows="2">
    <af:image id="imTemp2up" source="/images/anImage.jpg" inlineStyle="" shortDesc="...">
    <af:componentDragSource/>
    </af:image>
    <f:facet name="second">
    <af:dropTarget dropListener="#{dropHandler.handleComponentMove}" actions="MOVE">
    <af:dataFlavor flavorClass="javax.faces.component.UIComponent"/>
    </af:dropTarget>
    Any idea ?
    Thanks in advance,
    JP

    Hi,
    no bug that I can detect here as it works for me with the same setup. How likely is it that the image is too small so that you don't grab it probably the first time?
    Frank

  • Drag and dropping an address from address book to the desktop, the address file does not go where my mouse is positioned.

    If I drag and drop an address from address book to the desktop, the address file does not go where my mouse is positioned. It winds up somewhere in the middle of my screen. Any way to have the address file land and stay where my mouse pointer is?

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

  • How to drag and drop between portlets?

    Howdy!
    Could someone please be kind enough to show me how to drag and drop data between portlets. I want to select an icon, drag it to an application and launch the file associated with the icon in the application.
    I can do it within a portlet with some js functions but when I try it between portlets (on the same page)I see the forbiden sign.
    Thanks
    Jeff Graber

    Hi
    thanks for the advice. However, that is what I had done. Here is the code in the jsp file for the destination portlet and it does not work. If you have any ideas, thanks!
    <%@ page language="java" contentType="text/html;charset=UTF-8"%>
    <%@ taglib uri="netui-tags-databinding.tld" prefix="netui-data"%>
    <%@ taglib uri="netui-tags-html.tld" prefix="netui"%>
    <%@ taglib uri="netui-tags-template.tld" prefix="netui-template"%>
    <netui:html>
    <head>
    <title>
    MS Word Portlet
    </title>
              <script language="JavaScript" src="../js/common.js"></script>
              <script language="JavaScript" src="../js/containers.js"></script>
              <script language="JavaScript" src="../js/document.js"></script>
    </head>
    <body>
    Application Village Portlet
    <p>TextOre
    | <a id="MS Word" ondrop="sendInfo(this.id)" ondragover="fnCancelDefault()"><img src="/Jime/images/WORDY.gif" alt="Drag one or more documents here to open with MS Word" border="0"></img></a>
    | <a id="MS Excel" ondrop="sendInfo     (this.id);" ondragover="fnCancelDefault()"><img src="/Jime/images/EXCELY.gif" alt="Drag one or more documents here to open with MS Excel" border="0"></img></a>
    | <a id="MS PowerPoint" ondrop="sendInfo(this.id);" ondragover="fnCancelDefault()"><img src="/Jime/images/PowerPointY.gif" alt="Drag one or more documents here to open with MS PowerPoint" border="0"></img></a>
    | <a id="Trash" ondrop="sendInfo(this.id);" ondragover="fnCancelDefault()"><img src="/Jime/images/trashcan.gif" alt="Drag one or more documents here to delete" border="0"></img></a>
    </body>
    </netui:html>

Maybe you are looking for