How do I stop JEditorPane from auto-indenting subsequent text?

166
May 03, 2018, at 06:01 AM

My program loads an RTF file and displays it in a JEditorPane with the following code:

    public void ReadFile(String fileName) {
        RTFEditorKit rtfKit = new RTFEditorKit();
        StyledDocument doc = (StyledDocument) rtfKit.createDefaultDocument();
        rcp.getJEditorPane().setEditorKit(rtfKit);
        try {
            FileInputStream fi = new FileInputStream("Document.rtf");
            rtfKit.read(fi, doc, 0);
            rcp.getJEditorPane().setDocument(doc);
        } catch (FileNotFoundException e) {
            System.out.println("File not found");
        } catch (IOException e) {
            System.out.println("I/O error");
        } catch (BadLocationException e) {
        }
    }

Everything is going fine as long as I don't insert any indents, bulleted lists, or numbered lists in the original document. If the document does contain a one of these elements, all subsequent text is indented when displayed in the JEditorPane as well. It shows as follows:

1. This sentence is in the right position because it precedes the indent.
    2. This sentence is indented in the original RTF.
    3. This sentence and all other following sentences are not indented in the original RTF, but they become indented when displayed in the JEditorPane.

What I want is this:

1. This sentence is in the right position because contains no indent.
    2. This sentence is indented in the original RTF.
3. This sentence would be in the right position if it were like this.

Any solution using a TextArea or a TextPane instead of an EditorPane would also suffice.

Rent Charter Buses Company
READ ALSO
Camel - Designing scalable dynamic dataflow

Camel - Designing scalable dynamic dataflow

Use case: I receive a message from a source endpointDepending on the type of message, it gets handled by completely different business logic (e

185
Java app in docker: Failed to get driver instance for postgres

Java app in docker: Failed to get driver instance for postgres

I created a java web appWhen I run java -jar xxx

274
Nested hash map with hash map

Nested hash map with hash map

i want to create a hashmap that return this output:

212
How to declare 2D Arrays in Java and Implement them (Procedural Programming)

How to declare 2D Arrays in Java and Implement them (Procedural Programming)

I'm struggling to understand 2D arrays and my exam is in 2 days, I've tried myself but I just can't get my head around it so this is basically my last resort and I really need help understanding them

178