| The basic AWT framework offers a number of user interface components. 
              As discussed in Chapter 
              6: Java : AWT, the AWT components, are closely bound to their 
              peers in the windowing system on the local platform. These heavyweight 
              components thus generally take a lowest common denominator approach 
              for the sake of portability. However, in some cases, such as on 
              a platform with limited memory resources, you may want to avoid 
              using the Swing components. Here we look at some of the heavyweight 
              AWT components.  
              The Component 
                class extends Object 
                and is the base class for the AWT (as well as for Swing components). 
                All the visible elements of an applet or application are components 
                of one kind or another. The Component 
                class has a very large number of methods for dealing with all 
                aspects of the appearance, position, size, and other properties 
                of components. For example, the paint() 
                and getSize() 
                methods, which we used in several examples, come from the 
                Component 
                class (the Applet 
                class inherits Component). 
               See the Java API specification page for the Component 
                class to become familiar with all that it does.  The Container 
              class objects hold groups of components. The Panel 
              class is a commonly used container. In fact, the Applet 
              class inherits the Panel 
              class:    Object 
              <- Component <- Container <- Panel <- Applet The add(Component 
              a) method puts the component into the container. Since 
              containers themselves are components, they can in turn be added 
              to other containers. The arrangement of components within a container 
              is determined by the layout 
              manager to be discuss later.  The default layout manager for Panel 
              is the FlowLayout 
              which places the components left to right, top to bottom In this section we provide a demonstration program to illustrate 
              the basics of using the Button 
              and  Label 
              components. We also use a Canvas 
              as a drawing surface in another demonstrator. Other AWT heavyweight components include (corresponding Swing component 
              given in parentheses):   
             
              TextField 
                & TextArea 
                - to display text and also for text input. TextField 
                provides a single line whereas TextArea 
                is multi-line. 
                (JTextField, 
                JTextArea)Choice 
                - select a single item from this component which shows one item 
                but will display all of them in a "dropdown" menu when 
                clicked on. (JComboBox) 
              List 
                -displays several items in a scrollable list. (JList) 
              Checkbox 
                - make both checkbox and radio (only one selection allowed) buttons. 
                (JCheckBox, 
                 JRadioButton) 
              ScrollPane 
                - holds a component such as an image that is larger than visible 
                area. and provides crollbars to scan the component. (JScrollPane)Frame 
                - provides a standalone window to hold components for a GUI including 
                a menu bar with dropdown menus. (JFrame) 
              Dialog, 
                 FileDialog 
                - popup windows to interact with the user. (JDialog, 
                 JFileChooser)PopupMenu 
                - menu that floats above the interface. (JPopupMenu) The GUI example program uses several 
              of these components to demonstrate building an interface in the 
              AWT framework.    |