如何使用Java将图像和文本复制到剪贴板?

时间:2021-06-24 08:59:22

i want to copy image and text together to clipboard at same time but i can copy image or text

我想同时将图像和文本复制到剪贴板,但我可以复制图像或文本

//class to copy text
    StringSelection selection=new StringSelection(text);

 c.setContents(selection, null);
//class to copy image
                   ImageTransferable s=new ImageTransferable(image);


                       c.setContents(s, null);

1 个解决方案

#1


0  

You'll need to use a custom Transferable object:

您需要使用自定义的Transferable对象:

http://www.coderanch.com/t/345580/GUI/java/Cut-copying-pasting-custom-object

#1


0  

You'll need to use a custom Transferable object:

您需要使用自定义的Transferable对象:

http://www.coderanch.com/t/345580/GUI/java/Cut-copying-pasting-custom-object