• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

clipboard events?

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
reply
    Bookmark Topic Watch Topic
  • New Topic