AWT: The Abstract Windowing Toolkit
The AWT package is the core of Java's ability to do anything and
everything graphical. The AWT is abstract in that creating a 'button'
does not mean a specific look and feel to the button, but an
'abstract' button. This way, a Java applet running on a UNIX machine
will have a Motif look and feel and a Java applet running on a
MSWindows machine will have a MSWindows look and feel.
AWT Classes
AWT comes with a variety of graphical elements. Some of these include
buttons, dialog boxes, scroll bars, and text fields. AWT also comes
with a number of classes that are not necassarily something that
appears on your screen. These include graphics contexts, images, and
media trackers.
In order to actually use an AWT class, you need to have imported the
package as described earlier. From there instantiation of new objects
is straigtforward. For a very brief example, here is a bit of code
which will create a top level window and set it's size:
Frame f = new Frame();
f.resize(100,100);
f.show();
Drawing
class CircleWindow extends Frame {
CircleWindow() {
show();
resize(100,100);
}
public void paint(Graphics g){
g.setColor(Color.black);
g.drawArc(5,5,90,90,0,360);
}
}
Events
import java.awt.*;
import java.applet.Applet;
public class MyApp extends Applet {
int xval=10, yval=10;
public boolean mouseDown(Event evt, int x, int y){
xval = x;
yval = y;
repaint();
return true;
}
public void init() { }
public void start() { }
public void paint(Graphics g) {
g.setColor(Color.black);
g.drawArc(xval,yval,40,40,0,360);
}
}
Layout Managers
For more info about the awt package, see
http://java.sun.com/JDK-beta2/api/Package-java.awt.html.