-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathImageTransferable.java
More file actions
43 lines (37 loc) · 891 Bytes
/
Copy pathImageTransferable.java
File metadata and controls
43 lines (37 loc) · 891 Bytes
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
39
40
41
42
43
package dndImage;
import java.awt.*;
import java.awt.datatransfer.*;
/**
* This class is a wrapper for the data transfer of image objects.
*/
public class ImageTransferable implements Transferable
{
private Image theImage;
/**
* Constructs the selection.
* @param image an image
*/
public ImageTransferable(Image image)
{
theImage = image;
}
public DataFlavor[] getTransferDataFlavors()
{
return new DataFlavor[] { DataFlavor.imageFlavor };
}
public boolean isDataFlavorSupported(DataFlavor flavor)
{
return flavor.equals(DataFlavor.imageFlavor);
}
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException
{
if (flavor.equals(DataFlavor.imageFlavor))
{
return theImage;
}
else
{
throw new UnsupportedFlavorException(flavor);
}
}
}