/* * @(#)ImageTransferable.java * * $Date: 2011-02-24 00:42:26 -0600 (Thu, 24 Feb 2011) $ * * Copyright (c) 2011 by Jeremy Wood. * All rights reserved. * * The copyright of this software is owned by Jeremy Wood. * You may not use, copy or modify this software, except in * accordance with the license agreement you entered into with * Jeremy Wood. For details see accompanying license terms. * * This software is probably, but not necessarily, discussed here: * http://javagraphics.java.net/ * * That site should also contain the most recent official version * of this software. (See the SVN repository for more details.) */ package colorpicker.swing; import java.awt.Image; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.io.IOException; class ImageTransferable implements Transferable { Image img; public ImageTransferable(Image i) { img = i; } public Object getTransferData(DataFlavor f) throws UnsupportedFlavorException, IOException { if(f.equals(DataFlavor.imageFlavor)==false) throw new UnsupportedFlavorException(f); return img; } public DataFlavor[] getTransferDataFlavors() { return new DataFlavor[] {DataFlavor.imageFlavor}; } public boolean isDataFlavorSupported(DataFlavor flavor) { return(flavor.equals(DataFlavor.imageFlavor)); } }