This section discusses the use of the various built-in Component
s that process user input, i.e., buttons, text entry components, and list selection components.
Button
s:RadioButton
s:
CheckBox
es:
Echo provides various button components including simple pushbuttons (Button
s) and toggle-able buttons which provide a selection state (RadioButton
s and CheckBox
es).
Visual Appearance: All button components may be configured with colors, fonts, borders, background images, custom labels and custom icons. Mouse rollover and button-press effects may be set to alter the appearance of a button when the mouse is within its bounds and when it is being clicked, respectively. Using these various stylistic properties, buttons can be configured to look like HTML links or like traditional buttons found in a GUI application.
Packaging: The concrete button Component
classes may be found in the nextapp.echo.app
package. Supporting infrastructure including ButtonModel
s and the AbstractButton
and ToggleButton
base classes are found in the nextapp.echo.app.button
package.
Pushbuttons: The Button
component is a simple "push" button that provides the user with the capability to invoke an action. Pushbuttons have no selection state.
Checkboxes: A CheckBox
is a button which has an on/off selection state. If you click a CheckBox
, the selection state will be toggled.
RadioButtons: The RadioButton
component enables the user to select one option from a group of options. A RadioButton
can be assigned to a ButtonGroup
, which will allow only one of its member RadioButton
s to be selected at a time.
ActionEvents: When it is clicked, a Button
will fire an ActionEvent
to all registered ActionListener
s. If the ActionCommand
property of the Button
was set, this information will be included within the ActionEvent
. The use of action commands can be beneficial in circumstances where one ActionListener
is registered with more than one button.
ChangeEvents: A ToggleButton
will fire ChangeEvent
s in response to changes in its selection state.
All buttons are supported by a data model that implements the ButtonModel
interface which provides management of ActionListener
s. Toggle-able buttons are backed by a ToggleButtonModel
, which is a derivation of ButtonModel
that additionally provides selection state information and management of ChangeListener
s.
TextField
:A PasswordField
:
A TextArea
:
Text components provide the capability for the user to enter text data into an application. Echo provides three standard text components, all derived from the TextComponent
base class:
TextField: The TextField
component provides the capability to enter a single line of text.
PasswordField: A derivative of TextField
, PasswordField
adds a mask to user-input to facilitate on-screen password entry.
TextArea: The TextArea
component provides the capability to enter multiple lines of text.
The text displayed in a TextComponent
is held within a Document
data model object. DocumentListener
s may be registered with the Document
to receive notification of changes.
DocumentEvents: a TextComponent
's Document
model will fire DocumentEvent
s when it is changed.
ActionEvents: ActionEvent
s are fired by a TextComponent
when the enter key is pressed within the component.
The list components, i.e., SelectField
and ListBox
, provide the capability to select one or more items from a list of items. List components are derived from the AbstractListComponent
base class.
Packaging: The concrete list Component
classes may be found in the nextapp.echo.app
package. Supporting infrastructure including data model and selection model implementations are found in the nextapp.echo.app.list
package.
SelectField
:SelectField: A SelectField
is a compact list component that opens a drop-down list of selectable choices when clicked. SelectField
s only allow one item to be selected at any given time. Only the current selection is displayed when the SelectField
's drop-down is inactive.
ListBox:: A ListBox
displays a scrollable list of choices within a box. If configured appropriately, a ListBox
can allow multiple items to be selected simultaneously (the default behavior is to allow only one item to be selected at a time).
ListBox
:
A list component is backed by two models. A ListModel
is used to describe the items available for selection. A ListSelectionModel
describes the selection state of the list component.
ActionEvents: A list component will fire an ActionEvent
when an item is selected (if any ActionListener
s are registered).
ChangeEvents: The selection model of a list component will fire ChangeEvent
s when the selection state has changed.
Many of the components mentioned in this discussion have the capability to register very "fine-grained" event listeners which would result in substantial client-server traffic if the server were notified each time an event occurred. For example, a TextComponent
would fire a DocumentEvent
every time a character was typed. This would obviously be unacceptable for all but the fastest networks. To prevent such problems, the server will only be notified immediately in the event that the user performs an operation which will generate an ActionEvent
. Events such as ChangeEvent
s and DocumentEvent
s will be fired only when an ActionEvent
provides cause to contact the server.
When the server is contacted due to an ActionEvent
having occurred, it will first fire any cached delayed events (such as DocumentEvent
s and ChangeEvent
s) before the ActionEvent
is fired. Duplicate data model events will not be fired: for example, if a user has typed 100 characters into a text field, only one DocumentEvent
(rather than 100) will be fired.