Firm foundation in the main hci principles, the book provides a working


Download 4.23 Mb.
Pdf ko'rish
bet59/97
Sana23.09.2023
Hajmi4.23 Mb.
#1685852
1   ...   55   56   57   58   59   60   61   62   ...   97
Bog'liq
Human Computer Interaction Fundamentals

6.1 User Interface Toolkit
The UI toolkit is a library of precomposed UI objects (which would 
include event handlers) and a predefined set of events that are defined 
and composed from the lower-level UI software layer or the UI 
execution framework. The UI toolkit abstracts the system details 
of handling events and, as such, programming for interactive soft-
ware becomes easier and more convenient. The UI object often takes 
the form of a manipulable graphical object, often called a widget 


9 6
H U M A N – C O M P U T E R I N T E R A C T I O N 
(i.e., window gadget). A typical widget set includes menus, buttons, 
text boxes, images, etc. We have already examined typical widgets 
and UI objects in Chapter 4, which showed that widgets may be sin-
gular or composite (made up of several UI objects). The use of a toolkit 
also promotes the creation of an interface with a consistent look, feel, 
and mechanism. Here, we take a closer look at the toolkits through 
three examples. In particular, we examine how events are defined, 
how UI objects are created, how event handlers are specified, and how 
the interface (developed this way) is combined with the core func-
tional part of the application.
6.2 Java AWT UI Toolkit
Java, as an object-oriented language, offers a library of object classes 
called the AWT (Abstract Window Toolkit), which are classes useful 
for creating two-dimensional (2-D) UI and graphical objects [1]. The 
component is the most bare and abstract UI class from which other vari-
ant UI objects derive. Descendants (subclasses) from the component 
class include window, button, canvas, label, etc. The window class has 
further subclasses, such as frame and dialog. Each class has basic meth-
ods. For example, a window has methods for resizing, adding subele-
ments, setting its layout, moving to a new location, showing or hiding, 
etc. Figure 6.1 shows the overall UI object hierarchy and an example of 
the codes for creating a frame (a window with a menu bar) and setting 
some of its properties by the calling of such methods.
The Java AWT is not just a library of object classes for program-
ming, but also a part of the UI execution framework for Java that han-
dles a (large) subset of interaction events (called the AWTEvents). In 
general, the interaction events are sent to Java programs, where they 
are captured, abstracted, and stored as EventObjects. The AWTEvents 
are descendants of the EventObjects that cover most of the useful UI 
events (such as mouse clicks, keyboard input, etc.). The AWT frame-
work will map the AWTEvent to the corresponding AWT UI object. 
There are two ways for the UI object to handle the events.
The first is by overriding the (predefined) callback methods of the 
interactive applet object for the events. Table 6.1 shows the AWTEvent 
types and the corresponding callback methods that can be overridden 
for customized event handling. Figure 6.2 shows a code example for 


9 7
U I D E V E L O P M E N T T O O L K I T
Object
Component
Button
Frame
/* create a frame, a window with a menu bar */
my_frame = new Frame(“my frame”);
my_frame.show();
my_frame.resize( ... ); 
/* display it */
/* resize it */
/* create a menu bar */
menuBar mb = new MenuBar();
/* set the menubar for the frame */
my_frame.setMenuBar(mb);
. . .
Dialog
Window
ScrollPane
Panel
TextField
TextArea
MenuBar
Menu
PopupMenu
Checkbox
MenuItem
MenuItem
Applist
FileDialog
Label
Checkbox
Container
List
Choice
Text
Component
Scrollbar
Canvas
MenuComponent

Download 4.23 Mb.

Do'stlaringiz bilan baham:
1   ...   55   56   57   58   59   60   61   62   ...   97




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling