11.7 Adding controls to a Frame
|
|
GUI controls are added to a container using the add() method.
The parameters that the add() method accepts depends on the kind
of layout manager that the container has.
The standard AWT provides several GUI controls. The following is a partial
list:
-
Panel - A panel control can contain other controls.
-
Button - A button control
-
Label - A text label control
-
TextField - An edit box control
-
TextArea - A multi-lined edit box control
-
CheckBox - A check box control
-
ListBox - A List box control
The following code creates several controls and adds them to a container
that has a BorderLayout manager:
setLayout( new BorderLayout() );
add("North", new Button("North Button") );
add("South", new Button("South Button") );
add("East", new Button("East Button") );
add("West", new Button("West Button") );
add("Center", new TextArea() );