Jutanium
Jutanium

Reputation: 421

JEditorPane - switching back to the default editor kit

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?

Upvotes: 3

Views: 689

Answers (1)

trashgod
trashgod

Reputation: 205875

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.

Upvotes: 3

Related Questions