GridBagLayout
      GridBagLayout is also one of the Layout managers. In GridBagLayout you can place the components according to the coordinates specified hence making the task easier to be achieved.

import java.awt.*;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Nidhi
 */
public class GridBagLayout
{
    
     private Frame f;
     private Button b1;
     private Button b2;
     private TextField tf;
     private GridBagLayout g1;
     private GridBagConstraints gbc;
       
     public GridBagLayout()
    {
       f = new Frame("GridBag Layout"); 
       b1 = new Button("button1");
       b2 = new Button("button2");
       tf = new TextField("",20);
       g1 = new GridBagLayout();
       gbc = new GridBagConstraints();
    }
     
     public void launchFrame()
     {
         f.setLayout(g1);
         gbc.gridx = 30;
         gbc.gridy = 20;
         g1.setConstraints(b1,gbc);
         f.add(b1);
         
         gbc.gridx = 30;
         gbc.gridy = 30;
         g1.setConstraints(tf,gbc);
         f.add(tf);
         
         gbc.gridx = 30;
         gbc.gridy = 40;
         g1.setConstraints(b2,gbc);
         f.add(b2);
         f.pack();
         f.setVisible(true);
     }
     
     public static void main(String args[])
     {
         GridBagLayout g = new GridBagLayout();
         g.launchFrame();
     }
         
         
}
									

Download Program
Did You Know ?
IP address is a numerical label that is assigned to devices participating in a computer network. Read More