In this lesson, we continue the discussion of user interface components. Earlier, we looked at the components needed to build a basic user interface. They included:
FramePanelMenuBarMenuMenuItemScrollbarTextFieldHere, we will look at some of the other components that are available. These include:
LabelCheckboxChoiceListTextAreaPopup MenusWe will not look at
Buttonsince it was discussed in detail with respect toLayoutManager.User interface components are provided through the AWT package. Most are subclasses of the
Componentclass. The discussion here concerns the 1.1 event model.Because these components are relatively straight-forward, we will not provide a complete running applet until all have been discussed.
Labels
Labelsprovide a means to attach a heading to an interface component.Checkboxes
Checkboxesare two-state components that are either "on" or "off."Choices
The
Choiceclass provides a pop-up menu, from which only a single item may be selected at any one time.List
A
Listis a scrollable array of text items. The list may be setup in the constructor to allow either a single item to be selected at any one time or to allow multiple items to be selected.TextArea
A
TextAreais a scrollable multiline area for displaying text that may be either editable or not editable.Popup Menus
Popup menusare displayed when the user performs the platform-dependent triggering action.Complete Applet
The example program combines these components:
References
References useful for this discussion include the following:
- Sun's Java Development Kit (JDK)
- Sun's Java API
- Java API Class Hierarchy