1

Using the following code to copy a flat string to (windows) System Clipboard:

StringSelection selection = new StringSelection(string);
    Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
    clipboard.setContents(selection, selection); 

However this will only copy the text, Is there a why a string can be copied to the clipboard with formatting(RTF), so when pasted into another program e.g MS Word, the formatting is picked up?

(By formatting I mean for instance font, font size)

For example, I wish to copy the String : "Summary: Move waypoints to the left" in font size 12 Arial Font to the clipboard

kxdan
  • 187
  • 1
  • 15
  • A `Transferable` can have one or more `DataFlavor`s, you need to ascertain a data flavour which would be suitable, something like `text/html` (mimetype) for example – MadProgrammer May 24 '15 at 11:59
  • For [example](http://stackoverflow.com/questions/24966974/copy-jtable-row-with-its-grid-lines-into-excel-word-documents/24978019#24978019) and [example](http://stackoverflow.com/questions/15281679/copying-defaulttablemodel-data-to-clipboard/15283824#15283824) – MadProgrammer May 24 '15 at 12:01

0 Answers0