aspose file tools
The moose likes Applets and the fly likes selectable text -> copy to clpboard Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "selectable text -> copy to clpboard" Watch "selectable text -> copy to clpboard" New topic

selectable text -> copy to clpboard

glen croteau

Joined: Apr 10, 2008
Posts: 15
I am using graphics.drawChars to write static text to a signed applet. I would like to be able to select this text and copy it to the system clipboard. I have the copy to clipboard part working. However I need to find a way to allow the user to select the text which I will add to the StringBuffer and then transfer to the clipboard.

Advice please.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42956
Once it's drawn, the JRE has no idea that it was text to begin with, so unless you keep track of all text that is drawn and can retrieve it later during the "select" operation, this would be difficult to achieve (barring the use of OCR).

You'd also need to keep track of where on the Graphics which text is drawn (x/y coordinates), so that you can associate the user's selection with the text.
glen croteau

Joined: Apr 10, 2008
Posts: 15
Ulf, thank you for your response. Obvious now.
It is sorta covered in the JavaRanch Style Guide.
subject: selectable text -> copy to clpboard
It's not a secret anymore!