HTML code editor: a simple approach
Although SimplyHTML is mainly meant for text processing, sometimes it is useful to do a change directly in the HTML representation of a document. For this purpose a component to display and edit HTML code is required. The editor shall not replace a powerful web page HTML editor, it only adds basic HTML manipulation functions.
To implement such an editor an ordinary JEditorPane is used. Setting the content type to "text/plain" and adding the HTML code of a given document as content for the JEditorPane leads to have a fully working editor.
Obtaining the HTML code for a given text document
To get the HTML code for a given document which can be shown in above mentioned editor pane, class HTMLWriter (or SHTMLWriter, depending on the user selection) is used. The writer creates HTML code for any given instance of class Document and its subclasses. By using method getEditorKit of an EditorPane the EditorKit for a displayed document is taken. Method write of class EditorKit uses HTMLWriter implicitly.
See new method setHTMLView of class DocumentPane about how this approach is used.
Simple but not enough
While the above would already be enough to edit HTML for any given text document it is comparably hard to work with HTML in a plain text display. In plain text the structural elements of HTML are not visually separated from content elements. Thus, the next chapter explains how syntax highlighting is added to our new simple HTML editor for improved legibility.