• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

clipboard events?

 
morten wilken
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
does anyone know how to monitor if there is something in the clipboard.

i would like to enable or disable the 'paste' menu item depending on whether or not there is someting in the clipboard.

on a similar note i would also like to know how to monitor if a selection has been made in a textfield or area (in order to enable the 'copy' and 'cut' menu items.

does anyone have any leads?

sincerely
morten wilken
 
Ashish Vegaraju
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

check out the clipboard class in ur javadoc..there u will find getContents(Object objName) method. this method returns a "Transferable" object if the clipboard is empty it returns null.

use Transferable class to access the method getTransferData(DataFlavour dat); it returns an Object representing the data to be transfered.

u can use TextComponent class which is a super class of TextArea or TextField...a method named getSelectedText() is there use this method to get the selected text.

njoy
Ashish
 
morten wilken
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi anish,

thanks for your reply.

what i was looking for was an event that triggered when there was something in the clipboard, so i did not need to poll the clipboard object.

if i only want the paste option when something is in the clipboard the event approach seems obvious. i cannot find anything to do it though

sincerely
morten wilken
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic