Fundamentals of the AWT
The Abstract Window Toolkit can be used by Java applications and applets. But I recommend that:
- not use frames
- not use menus
But.. we will start with applications first of all, because of fewer restriction. 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 abstraction 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 the lack of 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. Albeit I've heard a Windows RC to AWT in development
- Class hierarchy is fairly shallow, but the AWT is not an application framework either. So it's missing
a doc/view architecture.
Since the JDK beta 2 has been released. Applets and Application tend to have similar functionality. Yet there
are times when an applet can not be a stand-alone app.
[More to be written...]
Steps for stand-alone applications using the AWT:
Since this is an AWT Tutorial we will focus on the interface part first and come back to
show how to integrate threading and networking into your applications(or applets).
- Create your Frame
- Do initialization of fonts, colors, layouts and other resources
- Create your menus and menubars
- Create your controls, dialogs, windows, etc.
- Add event handlers
- Add functionality(i.e threading, networking, etc)
- Add error-handling(i.e exceptions)
Last modified: Jan 2 1996