Drag and Drop in JTable never gets DropTargetListener events

I'm trying to implement Drag/Drop between two JTables. I have adapted the source from the Drag/Drop Tutorial but none of the DropTargetListener events get called. When I try to drag a row from one table to the other, the debug output is as follows:
beginning drag : ROW 3
dragsource : dragExit
dragsource : dragDropEnd
I'm using JDK 1.3. Any help would be appreciated, here is the source:
public class DnDTable extends JTable implements DropTargetListener, DragSourceListener, DragGestureListener
public DnDTable(Object[][] rowData,Object[] columnNames)
super(rowData,columnNames);
m_dropTarget = new DropTarget(this,this);
m_dragSource = new DragSource();
m_dragSource.createDefaultDragGestureRecognizer(this,DnDConstants.ACTION_MOVE,this);
public void dragEnter(DropTargetDragEvent event)
System.out.println("droptarget : dragEnter");
event.acceptDrag(DnDConstants.ACTION_MOVE);
public void dragExit(DropTargetEvent event)
System.out.println("droptarget : dragExit");
public void dragOver(DropTargetDragEvent event)
System.out.println("droptarget : dragOver");
public void drop(DropTargetDropEvent event)
System.out.println("droptarget : drop");
try
Transferable transferable = event.getTransferable();
// we accept only Strings
if (transferable.isDataFlavorSupported(DataFlavor.stringFlavor))
event.acceptDrop(DnDConstants.ACTION_MOVE);
String s = (String)transferable.getTransferData(DataFlavor.stringFlavor);
setValueAt(s,rowAtPoint(event.getLocation()),0);
event.getDropTargetContext().dropComplete(true);
else
event.rejectDrop();
catch(IOException exception)
exception.printStackTrace();
System.err.println( "Exception" + exception.getMessage());
event.rejectDrop();
catch(UnsupportedFlavorException ufException )
ufException.printStackTrace();
System.err.println( "Exception" + ufException.getMessage());
event.rejectDrop();
public void dropActionChanged(DropTargetDragEvent e)
public void dragGestureRecognized(DragGestureEvent event)
int nDragRow;
Object object;
nDragRow = getSelectedRow();
object = getValueAt(nDragRow,0);
if (object != null )
System.out.println("beginning drag:" + object.toString());
StringSelection text = new StringSelection(object.toString());
m_dragSource.startDrag(event,DragSource.DefaultMoveDrop,text,this);
else
System.out.println("nothing was selected");
public void dragDropEnd(DragSourceDropEvent event)
System.out.println("dragsource : dragDropEnd");
public void dragEnter(DragSourceDragEvent event)
System.out.println("dragsource : dragEnter");
public void dragExit(DragSourceEvent event)
System.out.println("dragsource : dragExit");
public void dragOver(DragSourceDragEvent event)
System.out.println("dragsource : dragOver");
public void dropActionChanged(DragSourceDragEvent event)
System.out.println("dragsource : dropActionChanged");
DropTarget m_dropTarget;
DragSource m_dragSource;

Hi My friend,
The code you have took will perfectly works.
I have an option please try this.
Instead of DnDConstants.ACTION_MOVE try DnDConstants.ACTION_COPY.
Lakshmi.

Similar Messages

  • Drag and drop file into email gets me an icon, not the image. Is there a simple fix?

    I am used to drag and drop image import into apple email. Recently I get a "mail attachment" icon for images that have been previously sent in other email. I would like to see the actual image in every email if possible. How can that happen?

    Thanks for the help. Dragging the thumbnail onto the album tab works great. Too bad this was not a bit clearer in the previous posts.

  • Is it possibiel to disable drag and drop of JTable columns?

    Hi,
    Using JDK6 I would like to disable user to drag and drop columns and change the default layout of my JTables.
    Thanks for any help,

    Using JDK6 I would like to disable user to drag and drop columns Read the JTableHeader API. You can prevent reordering of the columns.
    and change the default layout of my JTables.How do you expect us to answser this??? What do you mean by changing the layout? Whats wrong with row and column and what do you want to change it to?

  • Iphoto question. I have 8 images in an event. One is out of order. I have tried to copy and paste, and to drag and drop, but I cannot get it to move. Can anyone help?

    I have an iphoto question. I have 8 images in an event. One is out of order. I have tried to copy and paste, and  i have tried to drag and drop, but it won't move. Any help?

    IPhoto forum:
    https://discussions.apple.com/community/ilife/iphoto

  • Drag and Drop in jtable!

    Hi everybody!
    I want drag some element from some list and drop in some cell in jtable, but i have a problem because this element can use more than one cell, all depends! , the drag moviment seem to work fine between list and the JTable. when the drag cursor is above a row in the JTable, ONLY ONE cell in that row is highlighted, but i want that more than one cell get highlighted and i want put the information in more than one cell.
    Anyone know how to do that?
    thanks in advance
    ps:I am a freshman in foruns, sorry about my english.

    Hi everybody!
    I want drag some element from some list and drop in some cell in jtable, but i have a problem because this element can use more than one cell, all depends! , the drag moviment seem to work fine between list and the JTable. when the drag cursor is above a row in the JTable, ONLY ONE cell in that row is highlighted, but i want that more than one cell get highlighted and i want put the information in more than one cell.
    Anyone know how to do that?
    thanks in advance
    ps:I am a freshman in foruns, sorry about my english.

  • Drag and Drop inside JTable: what draws the 'insert' line during the drag?

    I'm trying to reconfigure a rather complex table with a fair number of custom renderers to include drag & drop of rows for resorting the table. Everything is working great, except that as I drag the rows there is no indication of the current insert point (i.e. the line that appears between rows). When I make a simpler table I see the line... I'm not sure what aspect of my current table is blocking this function. I'm writing in the hope that can someone can direct me to the method(s) responsible for drawing this line.
    Thanks!

    To elaborate a bit for anyone who might read this. I inquired with the Substance developers and they hope to support this feature in v5.1 (which requires SE6), but have no plans to update v4.3 (the last release before a switch to SE6).
    Also, I'd still be grateful for any info pointing me to the Swing methods that draw the drag line.

  • Drag and Drop from JTable

    Using cntl C and cntl V to copy data from a JTable
    into another file
    j2sdk1.4.0 copied the column names along with the data.
    j2sdk1.4.1_04 does not copy the column names anymore.
    Is there any way to get the previous functionality?

    Does anyone use cut and paste to copy data from a JTable to another file?
    I wonder why the new RE-Version doesn't copy the column headers anymore.

  • What does it take to drag and drop a jTable row to a jTextField?

    What kind of Listeners do I need? I have implemented transferListener and overrode createTransferable. But there was nothing responding when I tried to drag a row away. Any other Listener do I need to implement?

    For better help sooner, post an SSCCE.

  • I DRAG AND DROP A VIDEO CLIP FROM THE EVENT BROWSER THAT IS 7.9 SECONDS INTO MY IMOVIE I'VE STARTED AND IT CHANGES IN THE PROJECT TO 4.9 SECONDS - HOW CAN I KEEP THE LENGTH THE SAME

    I drag a video clip from Event to Project into my imovie I've started.  The video clip length changes from 7.9 seconds to 4.9 seconds. How can I stop that length from being changed?

    If you are using transitions either side of the clip they will use some of the clip to generate the effect, there isn't anything you can do unless you remove or shorten the transition.
    If you aren't using transitions it may be that you are only selecting part of the clip in the event window, try dragging out the yellow frame to include all the video you want in the project.

  • 10.7 Lion Install - Drag and Drop no longer works

    Just upgraded to Lion and my 'drag and drop' featuer works no where... No in finder (desktop to trash), Safari (customizing toolbar), or Dock (removing or rearranging icons). The rest of the track pad and all new gestures work flawlessly, but when I try to drag and drop an item it gets picked up and I can move it around, but it never 'drops'. The only way to get it off my cursor is to click the Apple logo in the top left corner.
    I've done some digging but all the tips I find aren't pertinent to my situation, or reference files that I somehow can't find on my machine. Any help would be greatly appreciated!

    I am having this issue too and bbiron is right, the only way to get the ghosted image of what you want to Drop detached from your cursor is to click the Apple menu.
    In addition to all the intances bbiron mentioned, which are all replicable by me as well, it also happens when I'm trying to drag links or tabs in Safari/Chrome.
    For the record, I did an upgrade from Snow Leopard and not a clean install of Lion. I'm using a MBP5,1 if that makes any difference as well.

  • Can't drag and drop mp3s to trekstor i.beat, keeps disconnecting the device

    Hi, am using snow leopard. In the past was perfectly able to use non ipod mp3 players. Now all of a sudden can't transfer mp3 via drag and drop to my new Trekstor i.beat. Yesterday tried an Archos, also did not work. What happens:
    when I drag and drop mp3 from desktop to player, the window copy to trekstor opens and starts to tell me how much time it will need for copying and then nothing happens for a while and then I get the message: "hard disk was not correctly disconnected" and the device is being disconnected. I then get the message: finder could not ...because data could not be read or written" (mistake: - 36)
    Sometimes I can drag and drop jpgs, but never mp3s. They are normal mp3s, not protected.
    Can anyone help? And no, I don't want to buy an iPod. Thanx
    iMac, Mac OS X (10.6.8)

    they are normal mp3 players and don't need to be compatible with apple. They can function as USB devices and normally be loaded with mp3s. I've tried this with other macs and it works fine. It used to work on my mac, too, but for some reason does not work anymore. There is something wrong with my software or settings and I would be very grateful if somebody could help me solve this problem.

  • Help needed in drag and drop of Flex tree

    Hi,
    We have an application which allows drag and drop between
    multiple
    trees and lists.
    Here are the steps I follow to refresh on drag and drop:
    1. Dispatch a custom event which calls server.
    2. On successful response from server I change the model
    which is
    data provider for the tree.
    3. Then, set a flag which triggers 'invalidateDisplayList'
    and 'invalidateList' for tree (and other listeners).
    4. The tree refreshes fine. But as soon as I drag and drop
    between
    trees again, I get this error in Tree.as:
    TypeError: Error #1010: A term is undefined and has no
    properties.
    at mx.controls::Tree/::updateDropData()
    at mx.controls::Tree/calculateDropIndex()
    at mx.controls.listClasses::ListBase/showDropFeedback()
    at mx.controls::Tree/showDropFeedback()
    The behaviour is weird, sometimes the browser hangs and stops
    responding.
    I am calling 'contentTree.showDropFeedback(event)' in my
    dragOver
    event listener which is triggering error.
    My tree data provider is a custom class which has 'children'
    array
    collection attribute.
    Any help on how to resolve this issue would be highly
    appreciated.
    Thanks in advance,
    Sujatha

    the major restrictions in its implemented only in
    jdk1.1.Why!

  • Resetting Wrong Answers only in a Drag and Drop Interaction

    Hello All,
    What I would like to see in the interaction is  -
    Learner drags items to a specific location
    clicks submit to check answers
    only the wrong answers reset to the original screen location
    feedback displays
    Learner trys again and repeats until all items are in the correct location.
    Is this scenario possible with the drag and drop?  I can get everything but the "only the wrong answers reset" to work.
    Any help would be greatly appreciated.
    Thank you in advance
    Kelli

    Not possible. Same as for normal question slides: Reset will reset everything. You can have the wrong answers getting back immediately, but it will not wait for Submit in that case.

  • I've found a bug in drag and drop in responsive projects

    I've created a simple, one slide project which has two sources and four targets. Before running the drag and drop wizard, the project previews and publishes. Once I've added the drag and drop wizard, it never previews nor publishes.
    Any ideas anyone?

    Having checked out D&D in responsive projects and did not see that problem.
    Maybe something got wrong when you updated? Did you delete the folders
    Layout, Preferences and Sample projects as instructed?

  • Drag and Drop does not work

    my iPhoto was working fine until the last update. Now, it won't let me drag and drop photos from my photos or events to albums, projects or galleries
    is there a setting that has changed...

    Problem solved from another post... sorry for the duplicate thread.
    As posted....
    Go to Font Book in your Applications Folder. Use it to rnable the Helvetica Fonts - if necessary, turn them off and back on again. Restart iPhoto.

Maybe you are looking for