aspose file tools*
The moose likes Beginning Java and the fly likes Clipboard Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Clipboard "event"" Watch "Clipboard "event"" New topic
Author

Clipboard "event"

Julien Castelain
Greenhorn

Joined: Sep 27, 2005
Posts: 28
hi all,

i have been looking for a way to get the contents of the System's clipboard
into a log file, after a few moments i was having a look at the java.awt.datatransfer package and related tutorials on the sun website.

i have one question though, while it seems quite easy and straight forward to retreive text from the clipboard (the global one) is their a way to be notified whenever the contents of the clipboard change
For example:
if the user copies, cuts or pastes text can the Java application be notified ?

thanks for your comments and help
cheers
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
are you using any of swing's text components?

if so there are methods for cut/copy/paste where you add your notification code
Julien Castelain
Greenhorn

Joined: Sep 27, 2005
Posts: 28
thanks for the advice michael,
i think, i didn't explain my problem correctly and i apologize,
i'd just like to know if a java application can "observe" the system clip board and be notified even if the java app is in the background ...

imagine you're copying text from a text file or a link in a browser, could the java app be notified ?

thanks again
julien
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

"julien,"

Please revise your display name to meet the JavaRanch Naming Policy. To maintain the friendly atmosphere here at the ranch, we like folks to use real (or at least real-looking) names, with a first and a last name.

You can edit your name here.

Thank you for your prompt attention!

-Marc


"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
Julien Castelain
Greenhorn

Joined: Sep 27, 2005
Posts: 28
i'm really sorry
i changed my name while i was updating my profile and i forgot to put my last name.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Cool. Thank you!
Scott Vail
Greenhorn

Joined: Dec 18, 2006
Posts: 1
Originally posted by julien:

i'd just like to know if a java application can "observe" the system clip board and be notified even if the java app is in the background ...

imagine you're copying text from a text file or a link in a browser, could the java app be notified ?


I have this same question and was wondering if someone knows the answer?
Preferably something that does not have to poll the system clipboard every (x) seconds.

Any help would be greatly appreciated.

Thanks,

Scott
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Have the class that owns the content posted to the clipboard implement the ClipboardOwner interface. This registers your class as an owner of the Clipboard and it will receive notice when someone else has asserted ownership of (ie, posted data to) the clipboard.
 
 
subject: Clipboard "event"