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


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

Re: JEditorPane question

From Jeff Higgins <jeff@invalid.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: JEditorPane question
Date 2014-12-08 20:48 -0500
Organization A noiseless patient Spider
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>

Show all headers | 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