-
Notifications
You must be signed in to change notification settings - Fork 369
/
ImageSelection.java
38 lines (30 loc) · 1.03 KB
/
ImageSelection.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Based on code snippet from
* http://java.sun.com/developer/technicalArticles/releases/data/
*
* Copyright © 2008, 2010 Oracle and/or its affiliates. All rights reserved. Use is subject to license terms.
*/
import java.awt.image.BufferedImage;
import java.awt.datatransfer.*;
public class ImageSelection implements Transferable {
private static final DataFlavor flavors[] =
{DataFlavor.imageFlavor};
private BufferedImage image;
public ImageSelection(BufferedImage image) {
this.image = image;
}
// Transferable
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException {
if (flavor.equals(flavors[0]) == false) {
throw new UnsupportedFlavorException(flavor);
}
return image;
}
public DataFlavor[] getTransferDataFlavors() {
return flavors;
}
public boolean isDataFlavorSupported(DataFlavor
flavor) {
return flavor.equals(flavors[0]);
}
}