1 | import java.awt.datatransfer.Transferable; |
2 | import java.awt.datatransfer.DataFlavor; |
3 | import java.awt.datatransfer.UnsupportedFlavorException; |
4 | |
5 | static class TransferableImage implements Transferable { |
6 | Image i; |
7 | |
8 | *(Image *i) {} |
9 | |
10 | public Object getTransferData( DataFlavor flavor ) |
11 | throws UnsupportedFlavorException, IOException { |
12 | if ( flavor.equals( DataFlavor.imageFlavor ) && i != null ) { |
13 | return i; |
14 | } |
15 | else { |
16 | throw new UnsupportedFlavorException( flavor ); |
17 | } |
18 | } |
19 | |
20 | public DataFlavor[] getTransferDataFlavors() { |
21 | DataFlavor[] flavors = new DataFlavor[ 1 ]; |
22 | flavors[ 0 ] = DataFlavor.imageFlavor; |
23 | return flavors; |
24 | } |
25 | |
26 | public boolean isDataFlavorSupported( DataFlavor flavor ) { |
27 | DataFlavor[] flavors = getTransferDataFlavors(); |
28 | for ( int i = 0; i < flavors.length; i++ ) { |
29 | if ( flavor.equals( flavors[ i ] ) ) { |
30 | return true; |
31 | } |
32 | } |
33 | |
34 | return false; |
35 | } |
36 | } |
see http://stackoverflow.com/questions/4552045/copy-bufferedimage-to-clipboard
download show line numbers debug dex old transpilations
Travelled to 19 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, onxytkatvevr, ppjhyzlbdabe, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1006061 |
Snippet name: | TransferableImage |
Eternal ID of this version: | #1006061/1 |
Text MD5: | 5bf2fb1950442a8566873b47f3cba0c3 |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-12-15 15:47:43 |
Source code size: | 1009 bytes / 36 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 496 / 7005 |
Referenced in: | [show references] |