• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help exporting to clipboard

 
Paul Celona
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just playing around with this, but it seems to work OK

 
Brian Pipa
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the code I use in Nator:
 
Paul Celona
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • 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 ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!