Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #30520

Re: JEditorPane question

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 Jeff Higgins <jeff@invalid.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: JEditorPane question
Date Mon, 08 Dec 2014 20:48:21 -0500
Organization A noiseless patient Spider
Lines 40
Message-ID <m65kei$7q3$1@dont-email.me> (permalink)
References <m64a5v$d3j$1@dont-email.me> <m659sr$5vl$1@dont-email.me> <m65car$d52$1@dont-email.me> <m65eus$nrp$1@dont-email.me> <m65h0h$tt5$1@dont-email.me>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Tue, 9 Dec 2014 01:49:06 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="c50a9e5d554cfaba13eda1c71e805135"; logging-data="8003"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+7bkhs1y2Su+AiIE2x6XAZvX68FZX1Whc="
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.2.0
In-Reply-To <m65h0h$tt5$1@dont-email.me>
Cancel-Lock sha1:w/4GKHdMFkLfSXmfb4qT6B7ZD7o=
Xref csiph.com comp.lang.java.programmer:30520

Show key headers only | View raw


Huh.
When I open LoremIpsum the \r\n pairs are there.
When I copy/paste from the console to a hex editor they're gone.

import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;

import javax.swing.JEditorPane;
import javax.swing.JFrame;
import javax.swing.text.DefaultEditorKit;

public class JEditorPaneTest {
    JFrame frame = null;
    public static void main(String[] a)
        throws FileNotFoundException, UnsupportedEncodingException {
       (new JEditorPaneTest()).test();
    }
    private void test() throws FileNotFoundException, 
UnsupportedEncodingException {
       frame = new JFrame("JEditorPane Test");
       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       frame.setSize(300,200);
       JEditorPane pane = new JEditorPane();
       pane.setContentType("text/plain");
       pane.setText(
          "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n\n"
          +"Nunc pellentesque quam et justo fringilla, eu gravida nunc 
tempus.");
 
pane.getDocument().putProperty(DefaultEditorKit.EndOfLineStringProperty, 
"\r\n");
       System.out.println(pane.getText());
       new PrintWriter("LoremIpsum", 
"UTF-8").printf(pane.getText()).close();
       frame.setContentPane(pane);
       frame.setVisible(true);

    }
}

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

JEditorPane question Martin Gregorie <martin@address-in-sig.invalid> - 2014-12-08 13:47 +0000
  Re: JEditorPane question Jeff Higgins <jeff@invalid.invalid> - 2014-12-08 17:48 -0500
    Re: JEditorPane question Martin Gregorie <martin@address-in-sig.invalid> - 2014-12-08 23:30 +0000
      Re: JEditorPane question Jeff Higgins <jeff@invalid.invalid> - 2014-12-08 19:14 -0500
        Re: JEditorPane question Jeff Higgins <jeff@invalid.invalid> - 2014-12-08 19:49 -0500
          Re: JEditorPane question Jeff Higgins <jeff@invalid.invalid> - 2014-12-08 20:48 -0500
            Re: JEditorPane question Jeff Higgins <jeff@invalid.invalid> - 2014-12-08 21:21 -0500
              Re: JEditorPane question Jeff Higgins <jeff@invalid.invalid> - 2014-12-08 21:37 -0500
      Re: JEditorPane question Jeff Higgins <jeff@invalid.invalid> - 2014-12-08 23:11 -0500
        Re: JEditorPane question Jeff Higgins <jeff@invalid.invalid> - 2014-12-08 23:28 -0500
          Re: JEditorPane question Martin Gregorie <martin@address-in-sig.invalid> - 2014-12-11 18:31 +0000
        Re: JEditorPane question Martin Gregorie <martin@address-in-sig.invalid> - 2014-12-09 09:41 +0000
        Re: JEditorPane question Jeff Higgins <jeff@invalid.invalid> - 2014-12-09 22:41 -0500
          Re: JEditorPane question Jeff Higgins <jeff@invalid.invalid> - 2014-12-10 00:46 -0500

csiph-web