Fundamentals of the AWT
The Abstract Window Toolkit can be used by Java applications and applets. But I recommend that:
Applets:
- not use frames
- not use menus
But.. we will start with applications first of all because we are less restricted. Although
I will try not to provide information too specific to stand-alone applications. The first few sections
are not particularly useful for applet writers, but later sections rely on concepts learnt early on.
Structure of the AWT
The current release of the AWT, has this type of of structure:
- Containers used to contain Components, which are your basic UI controls.
- Layouts vs. fixed positioning of Components.
- Lowest common denominator approach to keyboard, mouse and event handling.
- High level of abstract from the underlying GUIs. i.e no Non-clients areas, X calls, hWnds, etc.
- The look-and-feel of the application is dependant on the underlying GUIs rather than "one-size-its all".
- Not very device-independant(i.e can not assume a dialog will be the 'same size' on every computer) and lacks ability to 'draw to the printer' rather than the screen.
- Lacks a resource format. Thus the ability to separate code from the interface, via designing the interface
with a GUI builder and 'adding' event handling code.
- Class hierarchy is fairly shallow, but the AWT is not an application framework either. So its missing
a doc/view architecture.
[More to be written...]
Steps for stand-alone applications using
the AWT:
- Interface:
- Create your Frame
- Do initialization of fonts, colors, layouts and other resources
- Create your menus and menubars
- Create your controls, dialogs, windows, etc.
- Implementation
- Add event handlers
- Add functionality(i.e threading, networking, etc)
- Add error-handling(i.e exceptions)
Since this is an AWT Tutorial we will focus on the interface part first and come back to
show how you integrate threading and networking into your applications(or applets).
[Next]
[Prev]
[Home]
Nelson Yu
nelson@cs.ualberta.ca
Last modified: Dec 2 1995