In AWT, all the classes that can be displayed on the screen are the direct or indirect subclasses of the abstract class Component, (Component-->container), Container contains the Panel and window classes, The container class is a subclass of component, and he is also an abstract class that allows other components to join it. The added component also allows the container type, which allows multiple layers of nested hierarchical connectors. The container class is useful when the build is arranged on the screen in an appropriate form, it has two subclasses, Panel and window, and they are not abstract classes. The class of Window corresponds to Java.awt.Window, which can exist independently of other container and has two subcategories: frame and dialog. A frame is a window with a title and a resizable size. dialog does not have a menu bar, although it can be moved, but cannot be resized. The scroll panel (ScrollPane) is also a subclass of the window class. pane corresponds to a class of Java.awt.Panel, which can contain components of other container types, or contained in a browser window. The panel represents a rectangular area that allows other components to be placed. The panel must be placed in a window or its subclasses to display. One of the most important components of AWT is the menu, but he does not inherit from component, but inherits from the Menucompone that day, because the shape and use of the menu differs greatly from other visual components. Example: package title;import java.applet.applet;import java.awt.*;p Ublic class demotoolbar extends applet{ label mylabel; list mylist; button mybtn; choice mychoice;//check box TextField myText; Panel myPanel; Checkbox myChk1,myChk2; scrollbar myscrollbar; container con; public void&nbSp;init () { con = new container (); mylabel = new Label ("label Tag"); mylist = new list (3); mylist.add ("List"); mylist.add ("list"); mylist.add ("Show only three Rows"); mypanel = new panel (); mypanel.setbackground (color.red); mychk1 = new checkbox ("checkbox"); mychk2 = new checkbox ("check box"); mybtn = new button ("button-button"); mytext = new textfield ("TextField"); mychoice = new Choice (); mychoice.add ("Choice"); mychoice.add ("drop-down list"); myscrollbar = new scrollbar (scrollbar.horizontal,0,10,0,30); //set layout to 3 rows 3 columns Con.setlayout (New gridlayout (3,3)) //Add the above visual components to the container con.add (MyLabel); Con.add (myList); con.add (Mypanel); con.add (MYCHK1); con.add (MYCHK2); con.add (MYBTN); con.add ( MyChoice); con.add (MyText); con.add (Myscrollbar); add (con);//Add a container to the Applet object }}
Java java. The display of AWT in applets