Re: How String.copy(str) in java
Posted by
Michael Schmid on
Mar 21, 2016; 11:40am
URL: http://imagej.273.s1.nabble.com/How-String-copy-str-in-java-tp5015960p5015964.html
Hi Philippe,
you might try something like this (code stolen from
ij.plugin.frame.Editor; I used it in one of my plugins):
Clipboard clip = getToolkit().getSystemClipboard();
if (clip!=null) {
StringSelection contents = new StringSelection(s);
clip.setContents(contents, this);
}
The clipboard owner (a ClipboardOwner; here 'this' in setContents) seems
to be not critical; it can be also the StringSelection as long as you
don't need to know when the contents of the clipboard is modified.
http://stackoverflow.com/questions/8421007/java-clipboardowner-purposeMichael
________________________________________________________________
On 2016-03-21 12:17, Philippe CARL wrote:
> Dear all,
>
> I’m really sorry to have what is very probably a very easy question, namely
> "how to copy a String or Double to the clipboard within a plugin".
>
> This question is actually more or less similar to the conversion of the
> macro "String.copy(str)" instruction.
>
> Besides answering this question, I would as well be interested in how I
> could have find this information alone, i.e. without having posted this
> thread.
>
> Indeed, I have looked for "String.copy(str)" within ij.macro. Functions.java
> without being able to locate it (as well as already posted threads about
> such a question).
>
> I thank you very much in advance for your answer and help.
>
> Philippe
>
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html