11.7 Adding controls to a Frame

Previous Index Next 


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:

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() );