Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clipboard "event"

 
Julien Castelain
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"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
 
Julien Castelain
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cool. Thank you!
 
Scott Vail
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic