You are here: Home / Topics / Program to use GridLayout in Java

Program to use GridLayout in Java

Filed under: Java on 2023-10-25 06:45:00

//  Program to use GridLayout.

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

/*
<applet code="GridLayoutDemo" width="300" height="150">
</applet>
*/

public class GridLayoutDemo extends Applet 
{
Button b1, b2, b3, b4, b5;

public void init() 
{
 setLayout(new GridLayout(3, 2));

 b1 = new Button("Button-1");
 b2 = new Button("Button-2");
 b3 = new Button("Button-3");
 b4 = new Button("Button-4");
 b5 = new Button("Button-5");

 add(b1);
 add(b2);
 add(b3);
 add(b4);
 add(b5);
}
}

About Author:
J
Java     View Profile
Hi, I am using MCQ Buddy. I love to share content on this website.