Creating and storing documents

From the perspective of application SimplyHTML there is a distinction between documents as represented in package javax.swing and documents of application SimplyHTML. Package javax.swing provides a very powerful set of classes for working with documents, which relieves applications from having to completely implement their own editor, document model, etc.

How this set of classes is implemented in an application is left to the application developer however, allowing a maximum of flexibility while reducing effort and still retaining a common basis for the particular functionality.

Documents in Java

The package javax.swing implements a model-view-controller (MVC) approach to work with documents as shown below:

Document - the model for swing text components

EditorKit - the controller for text components

JTextComponent - the view component

The interface Document is a container for text that serves as the model for swing text components. The goal for this interface is to scale from very simple needs (a plain text textfield) to complex needs (an HTML or XML document, for example).

The abstract class EditorKit serves as the controller for text components establishing the set of things needed by a text component to be a reasonably functioning editor for some type of text content.

Abstract class JTextComponent finally is the view component in the MVC context serving as the base class for swing text components such as JEditorPane.

Documents in SimplyHTML

SimplyHTML defines an own class for dealing with the documents used in the application. Class DocumentPane is used to create new documents, load documents from file, save documents, view and edit documents and to define a SimplyHTML document in general.

With DocumentPane there is only one interface to deal with for both GUI and functionality when working with documents.