Java Programming

 

Abstract Windows Toolkit (AWT)

 

Java AWT uses three main types of classes to help you design a graphical user interface (GUI) for your applications and applets.

 

·                    Components are all the "widgets" or controls that you might use to design an interface to allow the user to put information into and get information from your program.  All of these components are derived from the java.awt.Component superclass.  Components have properties that you can set.  Some of these are its colors, fonts and dimensions.  All components have methods for drawing themselves.  The one you may call is the repaint() method, which will repaint the control.  Components also have methods for capturing and processing events.  Some examples of controls are Label, TextField, Checkbox, and Choice.

 

·                    Containers are components that are capable of holding other components.  Each container utilizes a layout manager to size and position those components within it.  The main method we use in a container is the add() method.  This method adds components to the container.  Some containers are Panel, Scrollpane, Window and Frame.  Of these the Panel is the simplest and most common container.  A Window container is a container with no borders, title bars, etc.  A typical use for a Window container is for creating splash screens.  A Frame container is one that has the borders, titles and menu bars.  A Frame container is the basis for a GUI application in java.

 

·                    Layout managers are responsible for positioning and sizing components within a container.  Each layout manager knows how to position each of the components inside the container and how to reposition them when the size of the container changes.  There are several different types of layout managers and each one performs its role of sizing and positioning components in different ways.  Some types of layout managers are GridLayout, FlowLayout, BorderLayout, GridBagLayout, and CardLayout.  Each container listed above has its default layout manager.  The default layout manager for applets and Panel containers is the FlowLayout.  The default layout manager for Frame and Window containers is BorderLayout.