Login  Register

Re: How String.copy(str) in java

Posted by CARL Philippe (LBP) on Mar 21, 2016; 3:25pm
URL: http://imagej.273.s1.nabble.com/How-String-copy-str-in-java-tp5015960p5015967.html

Dear Jan,
Thanks a lot for your answer and after it I really don't know (and
understand) how I could have missed what you pointed me out (especially
since I had found the String doString() method within Functions.java).
In all cases you closed a potential paradox and the only answer is that I
was blind this morning.
Thanks as well to Michael for his answer, but I wasn't able to reproduce the
" getToolkit().getSystemClipboard();" nor the " clip.setContents(contents,
this);" and the code I finally used is indeed similar to the one found in
copyStringToClipboard().
In fact I didn't really understand the ClipboardOwner issue about
setContents, i.e. the difference between setting the setContents
ClipboardOwner to "this", "null" or the StringSelection.
My best regards,
Philippe

-----Message d'origine-----
De : Jan Eglinger [mailto:[hidden email]] Envoyé : lundi 21 mars
2016 15:18 À : [hidden email]; [hidden email] Objet : Re: How
String.copy(str) in java

Hi Philippe,

to answer the second part of your question:

On 21.03.2016 12:17, Philippe CARL wrote:
> 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).

You were actually very close. Searching the file Functions.java for "copy"
gives 18 instances, among them the function copyStringToClipboard():

https://github.com/imagej/ImageJA/blob/master/src/main/java/ij/macro/Functio
ns.java#L4390-L4396

which uses code similar to the one the other answers are pointing to on
stackoverflow.com


Jan

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html