Text Entry Components

Figure 1: Inheritance diagram for
TextComponent-based classes.

Echo provides three built-in text entry components: TextField, TextArea, and PasswordField. The TextField component is used for single-line text input, TextAreas allow for multiple lines of input, and PasswordField provides for masked password entry.

Component Architecture

All of the built-in text entry components are derived from the TextComponent abstract base class, which provides common functionality such as holding the model and providing basic stylistic properties. The TextField and TextArea components are derived from this base class, offering single- and multi-line input capabilities respectively. PasswordField is a derivative of TextField which masks its input and attempts to prevent password information from being cached on clients.

Model-View-Controller Design

Echo's text entry components are built upon a model-view-controller architecture, which enables them to be adapted more efficiently to the various different circumstances that come about in application development. The model of a TextComponent is defined by the Document interface. This interface provides methods for updating and retrieving the state of the model, as well as to add and remove listeners to be notified when it has changed. An abstract base class, AbstractDocumentModel, provides a partial implementation of this model interface, taking care of the task of managing listeners and providing convenience methods to fire events to them.

The StringDocument class is a complete implementation of Document based on a plain Java String. StringDocument is the default model used when text components are created and no model is specified.