aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes clipboard events? 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 » Swing / AWT / SWT
Bookmark "clipboard events?" Watch "clipboard events?" New topic
Author

clipboard events?

morten wilken
Greenhorn

Joined: May 25, 2002
Posts: 13
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

Joined: Aug 19, 2004
Posts: 47
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

Joined: May 25, 2002
Posts: 13
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: clipboard events?