This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

clipboard events?  RSS feed

 
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
 
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
 
For my next feat, I will require a volunteer from the audience! Perhaps this tiny ad?
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!