Libraryless. Click here for Pure Java version (3639L/25K/84K).
!752 import java.awt.datatransfer.*; import java.awt.dnd.*; p-awt { final new ImageSurface is; showFrame(jscroll(is)); new DropTarget(is, new DropTargetAdapter { public void drop(DropTargetDropEvent e) { print("DropTarget: drop received"); handleFileDrop(e); } void handleFileDrop(DropTargetDropEvent evt) { pcall { Transferable tr = evt.getTransferable(); DataFlavor[] flavors = tr.getTransferDataFlavors(); for (DataFlavor flavor : flavors) { print("flavor: " + flavor); if (flavor.isFlavorJavaFileListType()) { evt.acceptDrop(evt.getDropAction()); L<File> list = (L) tr.getTransferData(flavor); if (list.size() != 0) { File file = list.get(0); is.setImage(loadBufferedImage(file)); } evt.dropComplete(true); return; } } } //print("Unknown data flavors (" + flavors.length + ")"); evt.rejectDrop(); } }); }
Began life as a copy of #1006011
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1006013 |
Snippet name: | Test making ImageSurface a drag&drop target v2 [WORKS] |
Eternal ID of this version: | #1006013/1 |
Text MD5: | 1821cf81ba5fa1bb755613449e32ee1d |
Transpilation MD5: | 1b590451afa07c0d0d81d27904891ab0 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-12-14 05:07:45 |
Source code size: | 1024 bytes / 38 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 4183 / 654 |
Referenced in: | #1006021 - jHandleFileDrop - makes any JComponent accept file drops (drag&drop) #1006022 - Drag&drop image files into this window! |