• 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

Need help exporting to clipboard

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wrote the following code snippet thinking that I would be able to copy text into the system clipboard so that I could paste it into another application. But the text doesn't seem to make it to the clipboard.

...
JLabel label = new JLabel(selectedData); // String selectedData holds text
label.setTransferHandler(new TransferHandler("text");
TransferHandler handler = label.getTransferHandler();
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
handler.exportToClipboard(label, clipboard, TransferHandler.COPY);

selectedData holds the text I want to export, but in WordPad the "Paste" button never gets enabled. Can anyone tell me why this doesn't work.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just playing around with this, but it seems to work OK

 
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's the code I use in Nator:
 
Paul Celona
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, I got the code working in JBuilder. Problem is I need to do this from an applet. running this in a web browser gives me an access denied/permission error when I try to access the clipboard. Is there a setting in MS IE that will allow my applet to write to the clipboard? How about Netscape? Anyone know?
[ May 21, 2004: Message edited by: Paul Celona ]
 
Can you really tell me that we aren't dealing with suspicious baked goods? And then there is this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic