1

I set a personal TransferHandler to my component:

myComponent.setTransferHandler(new PersonalTransferHandler());

class PersonalTransferHandler extends TransferHandler {
   public boolean canImport(JComponent comp, DataFlavor[] flavour) {
    ... 
   }
   protected boolean hasFlavor(DataFlavor[] flavors) {
    ... 
   }
   public boolean importData(JComponent comp, Transferable t) {
    ...
   }

Also I have a JTable with draggable elements (using another TransferHandler). I would like to copy elements from the JTable into myComponent. It works fine if the JTable is in the same JFrame that myComponent but if it is in a different JFrame I can drag the elements but I cannot drop into the compoment (the PersonalTransferHandler methods are not ever invoked).

Ivan
  • 1,477
  • 3
  • 18
  • 36
  • I never tried that but this issue is about System Clipboard, this is outside basic DnD – mKorbel May 16 '12 at 16:18
  • There is a solution but is not very clean. When you drag an element from JFrame1, setVisible(JFrame2) and then it works. – Ivan May 16 '12 at 16:38
  • I'd to suggest post the SSCCE here, but you have to wait for answer, [sure maybe no one](http://stackoverflow.com/questions/7745087/making-a-jeditorpane-with-html-put-correctly-formatted-text-in-clipboard) – mKorbel May 16 '12 at 17:26
  • See also [The Use of Multiple JFrames, Good/Bad Practice?](http://stackoverflow.com/a/9554657/418556) – Andrew Thompson May 16 '12 at 20:19
  • @AndrewThompson I know, but it is not my code. – Ivan May 17 '12 at 07:55
  • @StanislavL I don't use DropTarget. – Ivan May 17 '12 at 07:56
  • Are the frames in the same jvm? If so, it is much simpler. What are you trying to transfer? Objects, components etc? – MadProgrammer Jul 10 '12 at 17:37

0 Answers0