11.5 Layout managers 

Previous Index Next 


A layout manager controls how GUI components are laid out when they are added to a container. To set the layout for a container you use the setLayout() method, passing in an instance of the layout manager that you want to use.

The Java API provides several layout managers some of these are:

For example to set up a Frame so that it is using a BorderLayout manger you would use the following code:
Frame testFrame = new Frame("Test Frame"); // create a frame

testFrame.setLayout( new BorderLayout() ); // set frames layout

1