 I am Dr. Rishal Gajbar and in this video lecture, we are going to understand different layout managers for Java JOI applications. At the end of this session, you will be able to list different layout manager classes available in Java Swing and AWT packages. Now what is the use of layout managers? Layout managers help to put different components in the container classes. So there are different layout manager classes available in both AWT as well as Swing packages. In our today's video, we are going to understand these different classes which are available for layout managers and they are namely border layout, box layout, card layout, flow layout, grid bag layout, grid layout, group layout and we will finally see the spring layout. The first layout manager is a border layout. It is the default layout for JFrame objects. A border layout places components in up to five areas, top, bottom, left, right and center. All extra space is placed in the center area. Components in this case are added using the method called as add. So in this case, the object will be of container type and using that and the dot operator you are going to call the add method and inside there you are specifying the component which you want to add followed by the zone where you want to add the component. So this is the method which you can use for adding the components and the zone in this case can be follows border layout dot north for placing the component in the north direction. So in this case, this is page start. The next is border layout dot south which will put the component in the this place that is the pay in the south direction. Then the border layout dot west will put the components in this place that is line start and the border layout dot east will put the component in the right direction. So where you can see this label five and line end and finally by using the border layout dot center, this is the constant which you can specify for putting the components in the center part. And you need not place all components in all the five zones, it is not mandatory. The next layout manager is a box layout. So this class puts components in a single row or column. It respects components requested maximum sizes and also lets you along the components. So this is the example for the box layout. Now in this case you can see all the components are arranged vertically. So similarly you can also arrange the components in the horizontal direction also. The next layout is a card layout. The card layout class lets you implement an area that contains different components at different times. A card layout is often controlled by a combo box with the state of the combo box determining which panel or group of components the card layout displays. An example is shown here. Now in this case you can see this is the combo box which is used and in this case the combo box value is currently the card with J buttons and for this selection this area, the bottom area will display the three buttons, button one, button two and button three. For the different value of this combo box with the value as card with J text field then the same area will be replaced by different component called as text field. So this is the card layout. The next layout manager is a flow layout. Now flow layout is the default layout manager for every J panel object. It simply lays out components from left to right. So it will simply lay the components in a single row starting from a new row if container is not sufficiently wide. In this case you can see that button one, button two, button three, button four and these are arranged in a horizontal from left hand side to right hand side and the order in which the components are placed depends on how you are adding them while writing the class. So pause the video for two minutes and write down the answer of the given question. I hope you have written the answer. The default layout for J frame objects is border layout. The next layout manager is a grid back layout. Grid back layout is a sophisticated flexible layout manager. It aligns components by placing them within a grid of cells allowing component to span more than one cell. The rows in the grid can have different heights and grid columns can have different widths also. An example is shown here. So here you can see the button one, button two, button three all have the same width and height. However, the long named button four in this case spans the multiple cells and one can also observe the button with label five has different height and width than the rest of the buttons. So this is what you can achieve with the grid back layout. The next layout is the grid layout. The grid layout simply makes a bunch of components equal in size and displays them in a requested number of rows and columns. So for example, this is helpful for example when you are creating a calculator application. So in that case you want all the sizes of the button to be same. So in that case you can make use of this grid layout. In this case you can see the button one, button two, button three and all the buttons have the same height as well as same width. So this is what you can achieve with the grid layout. The next layout manager is a group layout. Group layout is a layout manager that was developed for use by joy builder tools but it can also be used manually. So group layout works with the horizontal and vertical layout separately. The layout is defined for each dimension independently. The next layout manager is a spring layout. A spring layout arranges the children of its associated container according to a set of constraints and the constraints in this case are nothing but horizontal and vertical distances between two component edges. Spring layout is a flexible layout manager designed for use by joy builders similar to the previous class. It lets you specify precise relationship between the edges of the components under its control. For example you might define the left edge of one component is a certain distance from the right edge of the second component. So this is about the spring layout. So on your screen is an example for the border layout. So in this case we have imported the necessary packages first then we have defined the class with the name demo border layout which extends the j frame class. Then we have declared the buttons which we want to add. So in this case these are declared to be the references of the j button class. So button north, button south, button center, button east and button west. Then in the constructor we will first of all set the layout for this class and this is to be border layout. So in this case we have written the method set layout and inside bracket we have passed the argument as new border layout and inside the bracket we have written 3,3. So 3,3 in this case specifies the horizontal and vertical gap between the components. In the next line what we have written is the button north is equal to new j button. So we are creating the object here of the j button class and here the label we are passing here is north. In next we are calling the add method. So add and here we are passing the component object button north comma and we want to put this in the north area. So for that purpose we are passing one constant namely border layout dot north. So similarly we are creating objects of the button south, button center, button east and we have put them in the appropriate position. Similarly in the constructor we will set the title to be border layout demo and we are setting the size of our j frame to be 280 comma 150, 280 is the width and 150 is the height. Then we will also set visible our frame to be true so that it is displayed on the screen and finally we have also written set default close operation method we have called this method and here we have passed the argument as j frame dot exit on close which will close the frame when we click on the exit button. And finally in the public static void main method we are creating object of our written class. So we are creating object of our class by writing new demo border layout. So let us see the execution of this program. So program is successfully compiled so let us run it. So here you can see we had declared 5 buttons and those buttons we wanted to put in different directions using the border layout. Here you can see the north button, east button, center, west and south. So this is about the border layout demo. So this is the reference. Thank you very much.