Question

If you change the editor kit of a JEditorPane to HTMLEditorKit, how do you change it back to the default (plain text) editor kit, like how it is when you first instantiate one? I want it to do this so that I can load all of the html and display it as plain text, not as formatted text, when the user switches to html mode (I'm making a dreamweaver-type app). I tried:

DefaultEditorKit kit = new DefaultEditorKit();
page.setEditorKit(kit);

But that makes the editor pane uneditable. How can I switch the editor kit back to plain text?

Was it helpful?

Solution

As discussed in Editor Panes vs. Text Panes, "Be aware that the document and editor kit might change when using the setPage() method." For plain text, they recommend a DefaultStyledDocument and StyledEditorKit.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top