// Grid Layout
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
public class grid extends Frame
{
Button b1,b2,b3,b4;
grid()
{
setLayout(new GridLayout(3,2));
b1 = new Button("one");
b2 = new Button("two");
b3 = new Button("three");
b4 = new Button("four");
add(b1); add(b2); add(b3); add(b4);
addWindowListener(new w());
}
class w extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}
public static void main(String arg[])
{
grid ff = new grid();
ff.show();
ff.setBounds(0,0,300,300);
}
}Java
Java - Grid Layout using Frame Demo.

Written by
View ProfileSenthilvelan Sambamoorthy
Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.
