站内搜索: 请输入搜索关键词
当前页面: 图书首页 > SWT: The Standard Widget Toolkit

6.1 Native Widgets Summary - SWT: The Standard Widget Toolkit

Previous Section  < Day Day Up >  Next Section

6.1 Native Widgets Summary

Figure 6.1 shows the class hierarchy for all of the native widgets provided by SWT. Four abstract classes define the basic structure (these are denoted by a small letter A beside the class icon in Figure 6.1).

Widget This is the root of the widget hierarchy. It defines the life cycle and event-handling API.

Control Controls are user interface elements that have operating system windows associated with them. These are typically called heavyweight widgets.

Scrollable The superclass of any control that has scroll bars.[3]

[3] Note that this is not an interface, despite the name.

Item Items are user interface elements that typically do not have operating system resources associated with them. These are typically called lightweight widgets.

Figure 6.1. Class hierarchy showing all native widgets.

graphics/06fig01.gif


Note that there is an additional class, Decorations, that is treated as an abstract class, although it is not marked as such.[4] This class was intended to be a placeholder for work in SWT to support the multiple-document interface (MDI) API found in Microsoft Windows. As such, the implementation of the Shell API is actually split between Shell and Decorations but is always described as though it were found in class Shell.

[4] This was an oversight that could not be corrected once SWT 1.0 had shipped. You should never create an instance of the class Decorations or reference this class anywhere in your code.

What follows are capsule descriptions of the concrete widget classes provided by SWT. As was already noted, these are described in detail in the next few sections that contain images of each widget. This will help if you are having trouble identifying them from their descriptions.

Caret Caret is an insertion point for text, sometimes called an I-beam. This class is useful only in conjunction with class Canvas.

Button Buttons represent all the buttonlike controls that are normally found in a widget system (push buttons, radio buttons, etc.).

Label Labels are static, passive controls capable of displaying either text or images. Labels are also used to display "separators" between other controls.

ProgressBar ProgressBar is used to display activity or degree of completion.

Sash Sashes are placed between controls and can be positioned by dragging. Note that moving Sash does not automatically reposition the controls that it separates, although you would typically add listeners to do this.

Scale Scale is a linear potentiometer that is used to measure either discrete or continuous quantities (such as the volume controls on a mixer).

Canvas Canvas is a general-purpose drawing surface.

Shell Shell represents all top-level windows on the desktop, including dialog boxes.

Combo Combo is a combination of Text and List controls used to display a selection of choices in a compact area.

CoolBar and CoolItem CoolBar displays moveable instances of CoolItem that can contain arbitrary widgets. These are almost exclusively used to position tool bars.

Group Group is a static control that draws a border around a set of other controls and optionally displays a title.

TabFolder and TabItem TabFolder displays a row of tab items that have the appearance of pages in a notebook.

Table, TableColumn, and TableItem Table is used to display tabular data, which can contain both text and images. Each column in the table is represented by TableColumn, and each row is described by TableItem.

ToolBar and ToolItem ToolBar is used to display one or more rows of buttonlike tool items.

Tree and TreeItem Tree is used to display hierarchical information, represented by multiple instances of TreeItem that can contain both text and graphics.

List List displays a single column of tabular data that can contain only text.

Text Text controls are single- or multiple-line text editors.

Slider Slider is a kind of scroll bar that can be placed anywhere in a composite.

Menu and MenuItem Menu allows an action to be chosen from a list of menu items. Menu bars, pull-down menus, and pop-up menus are all represented by instances of class Menu.

ScrollBar ScrollBar is used to scroll the contents of a control and is automatically positioned along the bottom and right[5] edges of the control.

[5] On BIDI (bidirectional) locales, this can be the bottom and left edges.

Tracker Tracker is used to allow the user to move or resize one or more rectangles on the screen. This kind of action is sometimes called rubber banding.

    Previous Section  < Day Day Up >  Next Section