package cc.woverflow.chatting.utils import java.awt.Image import java.awt.datatransfer.DataFlavor import java.awt.datatransfer.Transferable import java.awt.datatransfer.UnsupportedFlavorException data class ImageTransferable(private val image: Image) : Transferable { override fun getTransferDataFlavors(): Array { return arrayOf(DataFlavor.imageFlavor) } override fun isDataFlavorSupported(flavor: DataFlavor?): Boolean { return DataFlavor.imageFlavor.equals(flavor) } override fun getTransferData(flavor: DataFlavor?): Any { if (isDataFlavorSupported(flavor)) return image throw UnsupportedFlavorException(flavor) } }