1. Flow Layout:
- It is default layout manager.
- Components are laid out from the upper left corner,left to right and top to bottom.
- When no more components fit on a line, the next one appears on a new line.
• FlowLayout()
• FlowLayout(int align)
• FlowLayout(int align,int h gap,int v gap)
- Here align is the alignment left, right and center.
- H gap is the horizonatal distance and v gap is the vertical distance.
2.Border Layout:
- This class implements a common layout style for top-level windows.
- It has four narrow, fixed width components at the edges and one large area in the center.
- The four side are referred as north, south, east and west.
- The middle area is called the center.
• BorderLayout()
• BorderLayout(int horz,int vert)
- The horz and vert specify the horizontal and vertical distance between the components.
3.Card Layout:
- The cardlayout has some special capabilities that other layout do not have.
- It creates layout like playing cards.
- Assume that more that one card on one another so that only top card is visible at a time.
- But you can shuffle the cards to see other cards.
- This can be useful for user interface with optional components that can be dynamically enabled and disabled upon user input.
• CardLayout()
• CardLayout(int horz,int vert)
- The horz and vert specify the horizontal and vertical distance between the components.
4.Grid Layout:
- This class automatically arranges component in a grid.
- All components are created with equal size.
• GridLayout()
• GridLayout(int numRows,int numColumns)
• GridLayout(int numRows,int numColumns,int horz,int vert)
- The first constructor is default constructor which will create only one column grid.
- Here, rows and columns specify the number of row and columns of the grid.
- The horz and vert specify the horizontal and vertical distance between the components.
5.GridBag Layout:
- It is very flexible layout manager.
- It is an extension of GridLayout.
- In GridLayout all the cells have same height and width which is not necessary in the GridBagLayout.
- This can be done by specifying constraint.
- To specify constraint you have to create an object of GridBagConstraitns.
• GridBagLayout()
• GridBagConstraint()
- The GridBagConstraint are as follow:
-> gridx and gridy
- gridx specifies the horizontal position and the gridy specifies the vertical position of the component.
No comments:
Post a Comment