Name:Shravani Davang
Roll No:2223
Practical No:17
1. Java Program to Demonstrate Grid of 5 × 5
import [Link].*;
import [Link].*;
public class Grid5x5 {
public static void main(String[] args) {
JFrame frame = new JFrame("5x5 Grid Example");
[Link](400, 400);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](new GridLayout(5, 5));
for (int i = 1; i <= 25; i++) {
[Link](new JButton("Button " + i));
}
[Link](true);
}
}
Output:
Name:Shravani Davang
Roll No:2223
2. Java Program to Display Numbers on Buttons from 0 to 9
import [Link].*;
import [Link].*;
public class NumberButtons {
public static void main(String[] args) {
JFrame frame = new JFrame("Number Buttons 0-9");
[Link](300, 200);
[Link](JFrame.EXIT_ON_CLOSE);
[Link](new GridLayout(2, 5));
for (int i = 0; i <= 9; i++) {
[Link](new JButton([Link](i)));
}
[Link](true);
}
}
Output: