I want to copy string variable which has text on to clipboard. I tried many things but didn’t solve my problem. So please provide me some ideas or suggestions to solve this problem. Any help will be appreciated.
I want to copy string variable which has text on to clipboard. I tried many things but didn’t solve my problem. So please provide me some ideas or suggestions to solve this problem. Any help will be appreciated.
To copy string to clipboard uses the code given below:
String mg = "pouet";
StringSelection sers = new StringSelection(mg);
Toolkit.getDefaultToolkit().getSystemClipboard().s etContent(sers null);
try the code given below, this may helpful to solve your problem.
String str = jt.getSelectedText();
StringSelection strsel = new StringSelection(str);
Clipboard clbrd =
Toolkit.getDefaultToolkit().getSystemClipboard();
clbrd.setContents(strsel, strsel);
Bookmarks