I want to handle the drag event in a list using......
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Willie_Siavichay
Posted On:   Sunday, September 3, 2000 01:35 PM

I want to handle the drag event in a list using...


			
myList.addMouseMotionListener(this);
...
public void mouseDragged(MouseEvent e){
}

This work in PCs, but in Mac doesn't respond.


I want to change the list's items when the mouse is dragged.

Re: I want to handle the drag event in a list using......

Posted By:   Matthew_Schultz  
Posted On:   Friday, January 16, 2004 07:05 PM

After a bit of digging, I've found that the crash occurs in EventDispatchThread.class at:


void pumpEventsForHierarchy(int id, Conditional cond, Component modalComponent) {
while (doDispatch && cond.evaluate()) {
if (isInterrupted() || !pumpOneEventForHierarchy(id, modalComponent)) {
doDispatch = false;
}
}
}



I'm certainly NOT a Java guru, so if someone knows the answer to this, help would be appreciated! I'm willing to help debug the problem as I have access to both Mac and PC.

Re: I want to handle the drag event in a list using......

Posted By:   Matthew_Schultz  
Posted On:   Friday, January 16, 2004 06:24 PM

I've got it working on PC as well, but when I bring the code to a Mac, I get:


java.lang.ClassCastException
at sun.awt.datatransfer.DataTransferer.translateTransferable(DataTransferer.java:1189)
at apple.awt.CDataTransferer.translateTransferable(CDataTransferer.java:125)
at sun.awt.datatransfer.DataTransferer$5.run(DataTransferer.java:2018)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:178)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:170)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)


Basically, I've created a transfer handler and assigned it to the list:


public void mouseDragged(MouseEvent e) {
TransferHandler th = theList.this.getTransferHandler();
th.exportAsDrag(theList.this, e, TransferHandler.MOVE);
}


(The input adapter class is inline with the list class, which is why I've got theList.this.getTransferHandler())

Again, this works perfectly on Windows, but crashes immediately on the Mac. Additionally, my list stores a list of components, which when dragged on the PC shows a correctly sized outline. On the Mac, it shows an outline for the entire list.

Does anybody have code for implementing DnD on Mac OS X?

About | Sitemap | Contact