Layout Managers and Containers
by, 03-04-2012 at 04:26 PM (1189 Views)
A container must contain a layout manager to perform its work. If a layout manager is not associated with a container, the container will place the components wherever specified using following methods.
A layout manager must be present in a container so that work could be performed. If container and layout manager are not associated with each other, the components will be placed by the container wherever specified by using these methods.
Layout manager positions or sizes the components before they get painted, in case container and layout manager are not associated. Layout managerís responsibility is not to paint. Simply, its function is to decide that which position or size every component shall be occupying & calls setSize() , setBounds() & setLocation on every components.
LayoutManager is described by this code.
A constructor is provided by some containers like Panel.Java Code:Panel p = new Panel(); p.setLayout(new BorderLayout());
Java Code:Panel p = new Panel(new BorderLayout());