Dragging and dropping text from Word document to Java text component?

When you drag a block of text from a Word document to a Java Text Component, the text is removed from the Word document. In some cases, this is clearly undesirable. Is there a way that I can prevent Word from deleting the text but still copying it into the Java text component?

+1


a source to share


4 answers


Return false

from TransferHandler.importData(JComponent comp,Transferable t)

. You can save the data, but you tell the drag and drop system that you didn't accept it.



+3


a source


Try holding ALT, CTL or SHIFT (I forgot) while dragging. I believe this changes the default behavior of your cursor from cut -> copy.



You might be able to set the Drop Drop action in the copy-only JText component, I know you can do this in SWT.

+4


a source


I think this is the default behavior (it will happen even if you drag and drop text from one Word document to another). You can press the "Ctrl" key to achieve the desired results (Ctrl + Drag forces the copy operation).

+1


a source


Can't you use copy / paste? Selecting and dragging something around a Word document or from a word processing document to another document or text area is equivalent to cutting and pasting. Ctrl + C (copy) and Ctrl + V (paste) works just as fast.

0


a source







All Articles