Header

Wednesday 4 September 2013

IGNOU BCA 4th sem Solved Assignment - What is need of Layout Manager? Explain different layouts available in Java

What is need of Layout Manager? Explain different layouts available in Java
Ans
A layout manager is an object that determines the size and position of the components within a container. Although components can provide size and alignment hints, a container's layout manager has the final say on the size and position of the components within the container
We need Layour Manager because Layout manager really does 3 things:
1.      Set the location of a component. Since you need the ability to drag the component around, you would not want your layout manager to do this.
2.      Set the size of a component. Since you need the ability to resize the component then you would not want to do this. However, you might want to give the component a default size based on the components preferred size. This way you don't need to specify the size when you create the component.
3.      Determine the preferred size of the parent panel based on the components added to it. This will allow scroll panes to function properly as scrollbars can be added/removed as required. So you need to determine the behaviour of how dragging should work. That is, are you allowed to drag the component outside the current bounds of the panel. If so the the preferred size of the panel should automatically increase

A layout manager organizes the objects in a container 
Different layouts are used to organize or to arrange objects
- When there are only 5 elements to be placed, border layout is the right choice
- It lays out the components from left to right
- Controlled by a combo box, determining which panel the Card layout displays
- Allows certain components to span more than one cell 
- The rows of the grid are not of the same height and height


1. Border Layout:
- It has five areas for holding components: north, east, west, south and center 
2. Flow Layout:
- Default layout manager. 
3. Card Layout:
- Different components at different times are laid out 
4. Grid Layout:
- A group of components are laid out I equal size and displays them in certain rows and columns
5. Grid Bag Layout:
- Flexible layout for placing components within a grid of cells 

No comments:

Post a Comment