1.4 Drag and Drop - lost icons when added my own TransferHandler

I've been trying to implement drag-and-drop using a custom TransferHandler on JDK 1.4.
When I use the system default TransferHandler, I get nice icons that indicate whether the drop is allowed or not. Once I implemented my own TransferHandler, all I get is a dim grey outline when I drag -- the icon doesn't change when I drag to an area where acceptDrag() is being called versus one where rejectDrag() is being called. (I've got println's in the code so I can verify the accept/reject calls are happening, but the icon never changes).
It would be extra nice if the icon indicated whether a COPY or MOVE operation was selected, and toggled the icon appropriately.
From other messages in this forum, it appears that the getVisualRepresentation() method of TransferHandler is never called, so that would not help.
I don't really need customized behavior here; I'm just trying to get back the behavior I saw with the default TransferHandler. Any suggestions?
Thanks!
Mike Yawn

I've been trying to implement drag-and-drop using a custom TransferHandler on JDK 1.4.
When I use the system default TransferHandler, I get nice icons that indicate whether the drop is allowed or not. Once I implemented my own TransferHandler, all I get is a dim grey outline when I drag -- the icon doesn't change when I drag to an area where acceptDrag() is being called versus one where rejectDrag() is being called. (I've got println's in the code so I can verify the accept/reject calls are happening, but the icon never changes).
It would be extra nice if the icon indicated whether a COPY or MOVE operation was selected, and toggled the icon appropriately.
From other messages in this forum, it appears that the getVisualRepresentation() method of TransferHandler is never called, so that would not help.
I don't really need customized behavior here; I'm just trying to get back the behavior I saw with the default TransferHandler. Any suggestions?
Thanks!
Mike Yawn

Similar Messages

  • Drag and drop not working when uploading file using safari

    why i cannot drag and drop any file when using safari , and what happens the file auotmatically open while i need to upload it only , extra for that , i cannot write  any remark or fill a space while using website related to my work.
    my work is to upload drawing files using dwf file to a website so the other parties can review and give me review , and then i reply to the remark at the same place and make meeting through the same site.
    please any body can give any way to correct my mac.
    latelly i installed win7 only to use it for that website , and iam now changing from mac to win whenever i want to work , this not acceptable to me because it is waste of time beside i like the mac and it working with other application but not for safari.

    why ?
    I'm sorry, but every OS is different.  You cannot expect all features of one to be in another.  Or alternatively, for similar features, be done it the exact same way. 
    It looks to me after a quick google search that winexplorer is basically the moral equivalent of the mac's finder to present the file system in different ways.  The OSX Finder also has alternative views of the file system, i.e., icons, list, columns.  Experiment with the list and column views and see if one of them are more to your liking.
    As for winexplorer on the mac.  I don't know if this simulates it or not but there is a program called Macintosh Explorer so check that out as well.
    And finally, in the end, as I said in my earlier post, no matter what, nothing on the mac is going to change what I believe you think you can do and drop a file on a browser window and expect it to upload.

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

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

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

  • How to change this code to drag and drop image/icon into it??

    Dear Friends:
    I have following code is for drag/drop label, But I need to change to drag and drop image/icon into it.
    [1]. code 1:
    package swing.dnd;
    import java.awt.*;
    import javax.swing.*;
    public class TestDragComponent extends JFrame {
         public TestDragComponent() {
              super("Test");
              Container c = getContentPane();
              c.setLayout(new GridLayout(1,2));
              c.add(new MoveableComponentsContainer());
              c.add(new MoveableComponentsContainer());
              pack();
              setVisible(true);
         public static void main(String[] args) {
              try {
                   UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
              catch (Exception ex) {
                   System.out.println(ex);
              new TestDragComponent();
    }[2]. Code 2:
    package swing.dnd;
    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.*;
    import java.awt.dnd.DragSource;
    import java.awt.dnd.DropTarget;
    public class MoveableComponentsContainer extends JPanel {     
         public DragSource dragSource;
         public DropTarget dropTarget;
         private static BufferedImage buffImage = null; //buff image
         private static Point cursorPoint = new Point();
         public MoveableComponentsContainer() {
              setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED, Color.white, Color.gray));
              setLayout(null);
              dragSource = new DragSource();
              ComponentDragSourceListener tdsl = new ComponentDragSourceListener();
              dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, new ComponentDragGestureListener(tdsl));
              ComponentDropTargetListener tdtl = new ComponentDropTargetListener();
              dropTarget = new DropTarget(this, DnDConstants.ACTION_MOVE, tdtl);
              setPreferredSize(new Dimension(400,400));
              addMoveableComponents();
         private void addMoveableComponents() {
              MoveableLabel lab = new MoveableLabel("label 1");
              add(lab);
              lab.setLocation(10,10);
              lab = new MoveableLabel("label 2");
              add(lab);
              lab.setLocation(40,40);
              lab = new MoveableLabel("label 3");
              add(lab);
              lab.setLocation(70,70);
              lab = new MoveableLabel("label 4");
              add(lab);
              lab.setLocation(100,100);
         final class ComponentDragSourceListener implements DragSourceListener {
              public void dragDropEnd(DragSourceDropEvent dsde) {
              public void dragEnter(DragSourceDragEvent dsde)  {
                   int action = dsde.getDropAction();
                   if (action == DnDConstants.ACTION_MOVE) {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
                   else {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
              public void dragOver(DragSourceDragEvent dsde) {
                   int action = dsde.getDropAction();
                   if (action == DnDConstants.ACTION_MOVE) {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
                   else {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
              public void dropActionChanged(DragSourceDragEvent dsde)  {
                   int action = dsde.getDropAction();
                   if (action == DnDConstants.ACTION_MOVE) {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveDrop);
                   else {
                        dsde.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
              public void dragExit(DragSourceEvent dse) {
                 dse.getDragSourceContext().setCursor(DragSource.DefaultMoveNoDrop);
         final class ComponentDragGestureListener implements DragGestureListener {
              ComponentDragSourceListener tdsl;
              public ComponentDragGestureListener(ComponentDragSourceListener tdsl) {
                   this.tdsl = tdsl;
              public void dragGestureRecognized(DragGestureEvent dge) {
                   Component comp = getComponentAt(dge.getDragOrigin());
                   if (comp != null && comp != MoveableComponentsContainer.this) {
                        cursorPoint.setLocation(SwingUtilities.convertPoint(MoveableComponentsContainer.this, dge.getDragOrigin(), comp));
                        buffImage = new BufferedImage(comp.getWidth(), comp.getHeight(), java.awt.image.BufferedImage.TYPE_INT_ARGB_PRE);//buffered image reference passing the label's ht and width
                        Graphics2D graphics = buffImage.createGraphics();//creating the graphics for buffered image
                        graphics.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));     //Sets the Composite for the Graphics2D context
                        boolean opacity = ((JComponent)comp).isOpaque();
                        if (opacity) {
                             ((JComponent)comp).setOpaque(false);                         
                        comp.paint(graphics); //painting the graphics to label
                        if (opacity) {
                             ((JComponent)comp).setOpaque(true);                         
                        graphics.dispose();
                        remove(comp);
                        dragSource.startDrag(dge, DragSource.DefaultMoveDrop , buffImage, cursorPoint, new TransferableComponent(comp), tdsl);     
                        revalidate();
                        repaint();
         final class ComponentDropTargetListener implements DropTargetListener {
              private Rectangle rect2D = new Rectangle();
              Insets insets;
              public void dragEnter(DropTargetDragEvent dtde) {
                   Point pt = dtde.getLocation();
                   paintImmediately(rect2D.getBounds());
                   rect2D.setRect((int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),buffImage.getWidth(),buffImage.getHeight());
                   ((Graphics2D) getGraphics()).drawImage(buffImage,(int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),MoveableComponentsContainer.this);
                   dtde.acceptDrag(dtde.getDropAction());
              public void dragExit(DropTargetEvent dte) {
                   paintImmediately(rect2D.getBounds());
              public void dragOver(DropTargetDragEvent dtde) {
                   Point pt = dtde.getLocation();
                   paintImmediately(rect2D.getBounds());
                   rect2D.setRect((int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),buffImage.getWidth(),buffImage.getHeight());
                   ((Graphics2D) getGraphics()).drawImage(buffImage,(int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),MoveableComponentsContainer.this);
                   dtde.acceptDrag(dtde.getDropAction());
              public void dropActionChanged(DropTargetDragEvent dtde) {
                   Point pt = dtde.getLocation();
                   paintImmediately(rect2D.getBounds());
                   rect2D.setRect((int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),buffImage.getWidth(),buffImage.getHeight());
                   ((Graphics2D) getGraphics()).drawImage(buffImage,(int) (pt.getX()-cursorPoint.getX()),(int) (pt.getY()-cursorPoint.getY()),MoveableComponentsContainer.this);
                   dtde.acceptDrag(dtde.getDropAction());
              public void drop(DropTargetDropEvent dtde) {
                   try {
                        paintImmediately(rect2D.getBounds());
                        int action = dtde.getDropAction();
                        Transferable transferable = dtde.getTransferable();
                        if (transferable.isDataFlavorSupported(TransferableComponent.COMPONENT_FLAVOR)) {
                             Component comp = (Component) transferable.getTransferData(TransferableComponent.COMPONENT_FLAVOR);
                             Point location = dtde.getLocation();
                             if (comp == null) {
                                  dtde.rejectDrop();
                                  dtde.dropComplete(false);
                                  revalidate();
                                  repaint();
                                  return;                              
                             else {                         
                                  add(comp, 0);
                                  comp.setLocation((int)(location.getX()-cursorPoint.getX()),(int)(location.getY()-cursorPoint.getY()));
                                  dtde.dropComplete(true);
                                  revalidate();
                                  repaint();
                                  return;
                        else {
                             dtde.rejectDrop();
                             dtde.dropComplete(false);
                             return;               
                   catch (Exception e) {     
                        System.out.println(e);
                        dtde.rejectDrop();
                        dtde.dropComplete(false);
    }Thanks so much for any help.
    Reagrds
    sunny

    Well, I don't really understand the DnD interface so maybe my chess board example will be easier to understand and modify:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=518707
    Basically what you would need to do is:
    a) on a mousePressed you would need to create a new JLabel with the icon from the clicked label and add the label to the glass pane
    b) mouseDragged code would be the same you just repaint the label as it is moved
    c) on a mouseReleased, you would need to check that the label is now positioned over your "drop panel" and then add the label to the panel using the panels coordinates not the glass pane coordinates.

  • When I drag and drop an icon from the address bar to the desktop is does creat the shortcut but will not display the website icon, only the firefox icon, how can I display website icons?

    When I drag and drop a website icon from the Forefox address bar to the desk top, the short cut is created but the icon that appears is the firefox Icon. I want to disply the icon from the website that the short cut refers to. I have checked all I can think of in my computer to no avail.

    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.

  • Unable to drag and drop into trash when Numbers 09 is in use

    I wonder whether anyone can help me with this. When I have a spreadsheet open in Numbers 09, I can't drag and drop anything into trash. However if I minimise the spreadsheet, the drag and drop works!! Can anyone enlighten me as to why this is? I am very new to the Mac and am still learning+
    Thanks

    Report sent !
    *+Your tracking number for this issue is Bug ID# 6611461.+*
    +May you check the behavior of Numbers '09 under mac Os X 10.5.6 ?+
    +When used under macOsX 10.5.6, if we drag a file's icon above a Numbers window to drop it on the trash icon, the file is not trashed.+
    +I was able to reproduce this odd behavior several times.+
    +I must add that we may drag and drop to the trash without any problem when running under 10.4.11.+
    +Numbers is the unique iWork's component with this odd behavior.+
    +I don't know which is the culprit, Numbers or Finder but both of them are made in AppleLand.+
    +Happily, we may use the good old 'cmd + delete' shortcut but,+
    +an oddity is an oddity and it must be removed ;-)+
    Now, wait and see.
    Yvan KOENIG (from FRANCE dimanche 22 février 2009 22:15:22)

  • Change Drag and Drop Cursor/Icon

    When a drag and drop starts, a default icon/image appears under the cursor.
    Is there any way to change this icon/image ?
    thanks

    See this thread Drag/Drop cursor image
    The short answer is no.
    If you want the feature, submit a jira: http://javafx-jira.kenai.com and provide a link to the jira in this forum thread.

  • Cannot drag and drop to Albums when importing photos

    When you import images to Photos, you cannot drag and drop the photos to any of your albums.  What was Apple thinking by eliminating this organization feature that has been part of iPhoto since 1.0?  For example, when you import photos from your SD card (from your DLSR camera), you cannot drag and drop the photos to an album (when you have view sidebar selected).  If you select all the images, Photos for OS X will not let you drag and drop them anywhere.  Clicking on the selected photos to drag them will only de-select the photo you are hovering over.  How stupid is that?  How can Apple call that photo management?  People organize photos in Albums, but Photos for OS X only wants you to dump them into the program without any organization.  In order to drop the photos into an album, you have to import the photos and then click on Last Import.  Then select all the photos from that location, and then you can drag and drop them into an album.  Totally stupid.

    Solution may be found if you search in the "More Like This" section over in the right column. 

  • Drag and Drop error - icons are stuck to the cursor

    For the last few days when I try to use drag and drop, the items stick to the cursor and cannot be dislodged without a force quit or a reboot. That is they drag, but they do not drop. This is really sub-optimal.
    Has this happened to anyone else? How do I fix it?

    Idiot question - How do I re-install Leopard? No matter what I do, it kicks the disk out on restart. I have tried using the 'install' command on the disk, nothing. It kicks the disk out and boots from the hard drive. I have tried rebooting holding down the 'c' key to force it to read from the drive, it still kicks the disk out and boots from the hard drive. What else should I do?
    I researched back further and found another thread where people were complaining of the same drag and drop issue: http://discussions.apple.com/thread.jspa?messageID=6446208
    Someone suggested a solution involving permissions. I fixed my permissions. Drag and drop is still not working.
    There was also a set of commands to type into terminal that would supposedly fix the issue, or perhaps it was a Spotlight issue that the thread had morphed into. I did that. Drag and drop is still not working.
    Am I just totally hosed? Help!

  • Drag and Drop not working when Firefox is open

    I kept running into the problem and could not figure out why sometimes i could drag and drop and sometimes i could not.
    I just did some experimenting and found that as long as Firefox is minimized, drag and drop works fine.
    So the application can be open but all the windows need to be minimized.
    here is my firefox info Mozilla/5.0 Firefox/3.0.13

    I am having the same problem glasnostic you are not imagining things.
    I usually have finder set to detailed view mode and intermittently and seemingly randomly drag and drop will not work. I will be moving specific files from folder a to b then, all of a sudden, I click on a file like i did the last 10 and it wont budge. I found that like glasnostic switching to thumbnail view sometimes makes it work immediately. Otherwise just waiting a minute or two and trying again makes it work. This is so bizarre and is driving me crazy.
    I have experienced the same problem while attempting to drag files from finder into itunes.
    It happens to me without firefox open or running.
    The most recent time this happened I had open the following:
    -itunes (8.2.1)
    -Transmission (1.73)
    -ichat (4.08)
    -Safari (4.03)
    -Last.fm (1.542)
    on osx 10.5.8
    I'm using the logitech g5 mouse.

  • No Drag and Drop?  No library adding?

    I just started using iTunes and my Windows 7 machine. I had been using my Mac PowerBook, but it finally died.
    So, I've downloaded a bunch of stuff from an online site. It's all in zipped folders on my desktop. I can't seem to drag and drop any of them into iTunes. So, I took the files out of the zipped folders and onto my desktop. Still the same problem. The only thing I've found to work was to click and play the song.
    Also, it used to be on my Mac that if I played a song in iTunes it would automatically copy the file into my iTunes folder. This doesn't seem to be the case with my PC.
    I have it checked off to keep my library organized. Not sure what else to do. Any help here??

    Make sure the setting to "Copy files..." also has a checkmark, if you want them copied to the itunes folder.
    I'm not sure why the unzipped files won't add to itunes unless you play them.
    Are you sure they're unzipped? Or are you trying to drag them into itunes from the zip envelope?
    Right-click > Show in Windows Explorer on one of those files that you played.
    What folder is it in?

  • Cannot drag and drop, desktop icons disappear!

    When I try to drag any desktop icon, all of the icons disappear. Here's the crash report:
    Path: /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder
    Version: 10.3.3 (10.3.3)
    PID: 346
    Thread: Unknown
    Link (dyld) error:
    dyld: /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder Undefined symbols:
    /System/Library/CoreServices/Finder.app/Contents/MacOS/Finder undefined reference to _AddDragKtemFlavor expected to be defined in Carbon
    I used disk utility to repair permissions, did fsck -fy twice, to no avail. Any other suggestions?
    Thanks!

    Heather,
    You said: I have a sinking feeling that I'm headed for a full reinstall.
    In my opinion, it is still to early to consider that option.
    Before you attempt anything else, make sure that you have a proper backup.
    Then I would advise you to start in the "Safe Mode" and see if your problem persists. Let us know what happens.
    If you have no success with the Safe Mode, and decide upon reinstallation, an "Archive and Install" followed by the reinstallation of the Mac OS X 10.3.9 Update (Combo) would be my recommendation.
    ;~)

  • After installing iTunes 10.5.1, I can no longer drag and drop files into iTunes. Any suggestions?

    Basically when I try to drag files from a folder into iTunes, (drag and drop within iTunes is fine) the little picture of the circle with a slash through it shows up and wont allow me to drop it into iTunes. Does anyone know why this is happening and what I can do to fix it? Thanks. I'm so frustrated I'm about to smash my computer. I've tried uninstalling and reinstalling, restarting my computer, everything I can think of.

    just want to add my annoyance to the pile here. I can't see any logic behind removing the drag and drop function, especially when adding a new folder is now a multi-step process that is far from obvious. to start a new playlist with local folder content you now need to:enter settingsclick into advanced settings (basically all settings now seem to be "advanced"?)manually find and add the foldergo through the adventure of finding the files in your library.
    -- because they may or may not be listed under "local files" - you won't know because Ctrl+F is also removed. so you have to remember/know what the album you added is called and search for that. if you have a mixed bag of file names from various albums, you're basically shafted; there's no way to find them all with a single search.then you can add them to playlisteta: but wait! there's more! if you have more than 15 files? you're **bleep** out of luck, because the search will only display the first 15 hits among your local files, and then show you spotify library tracks.I can't help but feel as though spotify is doing everything they can to stop us using spotify to listen to local files, as bugs that make it more or less impossible persist through multiple versions - and now features that seem to me to be basic functionality are being removed?mega minus points from someone who's been using spotify since 2008.

  • How do I uninstall software not in my applications folder? The icon won't drag and drop to trash.

    I received a fitness device and downloaded the software. It didn't download to my Applications folder and I wasn't smart enought ot make sure I saved it there. Now the device doesn't work and I want to uninstall the software. I tried dragging and dropping the icon from Launchpad but that doesn't work. This lomg-time PC user turned Mac lover needs hlep!

    well this is strange, but hang with me a sec.  Some of these will sound obvious but i have to ask them.
    1)  Are you 100% sure it's not in your application folder?  (I have downloaded stuff and looked for a while without seeing the app RIGHT in front of me).
    2) The hard thing to believe is that it is in your launchpad but NOT in your application folder. 
    3) Try downloding it again....it might find the detect the old version and overwrite it.  I have never downloaded an app that did not automatically download to the applications folder, but if this one did, check to see what option it gives you to dowload to by default.  That way you can see maybe where it was installed to, and thus find it and delete it.  then reinstall to the applications folder.
    let me know

  • Problem with drag and drop on Mac

    Hi, when I run my AIR application on Windows, I'm able to do
    the drag and drop.
    But when I run the application on Mac, it gave me an
    allocation error: unable to allocate region of size <random
    number> after I drag and drop thrice.
    Anybody knows what's the reason?

    Pages does not support the Apple font used for color emoji, so that behavior is normal.
    With what app are you reading the yahoo mail?  There is really no guarantee than any other email service will show the special Apple font involved.
    You should have no problem putting emoji directly into Mail or Text edit via drag drop from the Character Viewer as shown below.
    You should also be able to upload graphics here easily by clicking on the camera icon.  My email is tom at bluesky dot org.

Maybe you are looking for

  • How to handle iTunes Match with multiple libraries (one account, 5 family members)?

    How would this work, in the situation below ... Everyone has their own iCloud account (for their own syncing purposes). But we (family) ALL share the same iTunes account (for purchasing). How will this work, since we all have our own iTunes libraries

  • Electronic Bank Statement Determining Incorrect Business Partners

    Have an issue with some electronic bank statements we import into SAP. Several of the line items we get from the bank identify the incorrect business partner when creating the payment advice. We are using intepretation algorirthm 001 to interpret the

  • Adding a new column to af:query on af:table

    Hi, I have an ADF table added to a jspx page as below: <af:table value="#{bindings.RuleLibraryVO1.collectionModel}" var="row" rows="#{bindings.RuleLibraryVO1.rangeSize}" emptyText="#{bindings.RuleLibraryVO1.viewable ? coregccomplianceuiBundle.MSG_NO_

  • Startup/Hard Drive Failure on iBook G4

    My iBook G4, bought about two and a half years ago, recently developed a very serious problem. Occasionally, on startup, I get a blank screen, then a flashing folder icon with a question mark/Mac OS icon. This happens erratically. Sometimes the compu

  • Exporting jpegs-- why do I get 72ppi when i set resolution at 240ppi ?

    Why does Lightroom export jpegs at 72ppi resolution-- when I clearly set it at 240ppi in the export window? It has done this for versions 1.0-1.2. For exporting psd or tiff-- everything works as planned. Anyone have a solution? Thanks.