View RSS Feed

Java AWT

Layout Managers and Containers

Rate this Entry
by , 03-04-2012 at 04:26 PM (1107 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.

  1. setBounds()
  2. setSize()
  3. setLocation()


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.
Java Code:
  Panel p = new Panel();
  p.setLayout(new BorderLayout());
A constructor is provided by some containers like Panel.
Java Code:
 Panel p = new Panel(new BorderLayout());

Submit "Layout Managers and Containers" to Facebook Submit "Layout Managers and Containers" to Digg Submit "Layout Managers and Containers" to del.icio.us Submit "Layout Managers and Containers" to StumbleUpon Submit "Layout Managers and Containers" to Google

Categories
Layout

Comments