clipboard.setContents destroys clipboard.getContents?

S

spunibard

when i'm using clipboard.setContents to reset clipboard information it
is breaking clipboard.getContents. (getContents will return whatever
setContents set regardless of the outside program putting information
on the clipboard. this was not a problem until setContents was added.
am i doing or expecting something wrong?

java.awt.datatransfer.StringSelection ss = new
java.awt.datatransfer.StringSelection(s);
this.clipboard.setContents(ss, ss);

(...)

this.clipboardTransferable = this.clipboard.getContents(null);
try {
return
this.clipboardTransferable.getTransferData(java.awt.datatransfer.DataFlavor.stringFlavor).toString();
}
 
A

Andrew Thompson

when i'm using clipboard.setContents to reset clipboard information it
is breaking clipboard.getContents. (getContents will return whatever
setContents set regardless of the outside program putting information
on the clipboard. this was not a problem until setContents was added.
am i doing or expecting something wrong?

I would need to see an SSCCE* to determine if
what you say (and the code) makes any sense.
* <http://www.physci.org/codes/sscce.html>

Andrew T.
 
S

spunibard

Thanks Andrew, you helped me figure this out- After writing an SSCCE i
found that my problem seemed to be outside of where i was looking.
(SSCCE worked great) eventually i found (i think) that because the
process wasn't running in it's own thread, it seemed to be getting in
the way of itself when it came to the clipboard owner changing. which
is odd (to me) because as long as the ownership of the clipboard
didn't switch to my program, the clipboard stayed current just fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top