Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: JEditorPane question Date: Thu, 11 Dec 2014 18:31:47 +0000 (UTC) Organization: A noiseless patient Spider Lines: 29 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 11 Dec 2014 18:31:47 +0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="4016"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/wVDeUwbtRG3438lkkVHm8tDiy4YkcDY4=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:l0dCKhhqLhHtgChMEzmxI34QFFw= Xref: csiph.com comp.lang.java.programmer:30539 On Mon, 08 Dec 2014 23:28:59 -0500, Jeff Higgins wrote: > should be: > source.getText().substring(p0.getOffset(), p1.getOffset()); > Thanks for the tutorial in using the TransferHandler class and for the correction shown above, but cut and paste still doesn't seem to be getting CRLF: without that correction cut and paste seems to be duplicating LF, i.e. the double newline in the middle of your examole test becomes LFLFLFLF and with the correction I'm seeing LFLF. In both cases the text, when grabbed with getText() and sent to System.out or written to a file via the PrintWriter, shows CRLFCRLF. So, it looks very much as though copying and pasting text with CRLF isn't going to be at all easy. I tried adding String.replace() into the last line of CreateTransferrable(): return new StringSelection(data.replace("\n", "\r\n")); but that merely doubled the number of "\n" symbols output, so I think the way to go will be to modify the website to accept both Linux and Windows linebreaks. Thanks for your help: I've learnt quite a lot about this part of Swing. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |