GeeCON Prague 2014*
The moose likes Java in General and the fly likes Rich Text (formatted) in Clipboard? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Rich Text (formatted) in Clipboard?" Watch "Rich Text (formatted) in Clipboard?" New topic
Author

Rich Text (formatted) in Clipboard?

marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

I have a simple class that takes a string and puts it on the clipboard...

My ultimate goal is just to format the string in the clipboard so that it pastes into MS Word as bold. How can I modify the code to do this?

Note: I'm working in Lotus Notes with the lotus.domino package, so I do have a RichTextItem class. I can get a MIMEEntity from my RichTextItem, which I believe allows me to create a new DataFlavor, which I'm guessing I'll need in creating a Transferable object that I can pass to the setContents method. This is where I'm stuck. I'm not sure how to connect these dots -- or even whether I'm headed in the right direction.
[ September 14, 2005: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 687
    
    1
Sorry, I can't tell you how to do it. But here's an idea:
To see what is put on the clipboard, create the desired text in Word/?? and copy it to the clipboard and then have a java program with lots of println()s look at what is in the clipboard. That should show you what you need to put there.
Norm Radder
Ranch Hand

Joined: Aug 10, 2005
Posts: 687
    
    1
There is sample code for putting something on a clipboard in "Core Java, Volume II" by Horstmann and Cornell.
You can also probably find samples by using Google.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Norm Radder:
There is sample code for putting something on a clipboard in "Core Java, Volume II" by Horstmann and Cornell...

Thanks! I'll check that tonight. Those are great books -- although I haven't read the Swing chapter yet, which is where I'm guessing this is.

(Note: I tried looking at clipboard contents using Java code, but I'm stuck on how to work with the Transferable object. I think I need to downcast it to something based on an appropriate DataFlavor, but I don't know exactly what. This seems to be the same roadblock I hit approaching the problem from the other direction.)
[ September 15, 2005: Message edited by: marc weber ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Rich Text (formatted) in Clipboard?