ClipboardUtils - easily copy text and images (also combined as rtf)

From: Meikel (m.bisping_at_gmx.de)
Date: 03/21/04


Date: 21 Mar 2004 08:58:40 -0800

I created a ClipboardUtils class which makes it easy to copy Strings
or images to the clipboard.
I don't claim that it's no way perfect, but has been useful in my
applications so far. If you try it out and have improvement
suggestions, let me know.
It can also copy a graphical image of any JComponent to the clipboard.

I also wondered how I could copy text AND images to the clipboard at
the same time (e.g. an image with some explanatory text below). Just
creating a Transferable which supports stringDataFlavor and
imageDataFlavor isn't enough.
I realised that one way to do it, is to create a rtf (RichTextFormat)
document.
(This can be done nicely with iText or manually according to the
rtf-specification).
I also wrote a little sample application which places an rtf into the
clipboard (it needs itext.jar from www.lowagie.com/itext)
The ClipboardUtils-class together with a little sample application can
be found at
http://www.mbisping.de/java/ClipboardUtils.zip (14K)



Relevant Pages

  • Re: Embedded vs Linked - Default?
    ... Wordpad or more to the point, changed the clipboard, when it installed. ... to be on the internet to view the images in my documents. ... To me, that is extra effort. ...
    (microsoft.public.word.docmanagement)
  • Re: Embedded vs Linked - Default?
    ... I usually save graphics as files instead of pasting them directly. ... please post all follow-ups to the newsgroup so ... > Wordpad or more to the point, changed the clipboard, when it installed. ... > to be on the internet to view the images in my documents. ...
    (microsoft.public.word.docmanagement)
  • Disallowing pasting of images in RTF, only text
    ... be inserted in the rtf by pasting it from the clipboard. ... stop any images being pasted in my rtf. ... and then if the user presses ctrl+v to paste; ...
    (microsoft.public.vb.general.discussion)
  • Re: Embedded vs Linked - Default?
    ... If the document contains nothing but linked images, then Ctrl+A, ... paste copied images from the Web. ... To me, that is extra effort. ... > Do you know WHY the clipboard worked last month (accepting data from the ...
    (microsoft.public.word.docmanagement)
  • Re: Muddy graphics
    ... Download the free IrfanView graphics editor and install it. ... But when I insert the images into the Word document, they are quite muddy and blurred. ... I've also tried opening the files in Irvanview, copying the images to the clipboard, then pasting the clipboard into the Word document, with the same muddy results. ...
    (microsoft.public.word.newusers)