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

如何使用Java将图像和文本复制到剪贴板?,java,Java,我想同时将图像和文本复制到剪贴板 但我可以复制图像或文本 //class to copy text StringSelection selection=new StringSelection(text); c.setContents(selection, null); //class to copy image ImageTransferable s=new ImageTransferable(image);

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

//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);

您需要使用自定义的可转移对象: