0% found this document useful (0 votes)
8 views2 pages

Practical17 Java

The document contains two Java programs created by Shravani Davang, demonstrating GUI applications using Swing. The first program creates a 5x5 grid of buttons labeled from 1 to 25, while the second program displays buttons labeled with numbers from 0 to 9 in a 2x5 grid layout. Both programs set up a JFrame and utilize GridLayout for arranging the buttons.

Uploaded by

abhichavan1206
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Practical17 Java

The document contains two Java programs created by Shravani Davang, demonstrating GUI applications using Swing. The first program creates a 5x5 grid of buttons labeled from 1 to 25, while the second program displays buttons labeled with numbers from 0 to 9 in a 2x5 grid layout. Both programs set up a JFrame and utilize GridLayout for arranging the buttons.

Uploaded by

abhichavan1206
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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:

You might also like