I have a swing application and I want to copy some text to the system clipboard. I do this with
Clipboard systemClipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection dataToClipboard = new StringSelection(stringToCopy);
systemClipboard.setContents(dataToClipboard, null);
But it exists only inside the app, I can paste it in any text field in it, but when I try to do so in a web browser, it pastes nothing.
I also tried to implement ClipboardOwner interface and pass it's reference instead of null
, but it didn't make a difference.