0% found this document useful (0 votes)
18 views9 pages

Ajp 3

The document describes two Java programs written by student Ekambe Ganesh. The first program creates a 5x5 grid of buttons labeled 1-25. The second program displays buttons labeled 0-9 in a grid. It also includes exercises to create a grid layout with 5 buttons and use a border layout with buttons in the north, south, east, west and center sections.

Uploaded by

Ganesh Ekambe
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)
18 views9 pages

Ajp 3

The document describes two Java programs written by student Ekambe Ganesh. The first program creates a 5x5 grid of buttons labeled 1-25. The second program displays buttons labeled 0-9 in a grid. It also includes exercises to create a grid layout with 5 buttons and use a border layout with buttons in the north, south, east, west and center sections.

Uploaded by

Ganesh Ekambe
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
You are on page 1/ 9

Name of Student: Ekambe Ganesh Roll No.

: 53
Experiment No.: 03 DOS:

X. Program Code:

1. Write java Program to Demonstrate Grid of 5* 5.

import java.awt.*;
public class Grid
{
public static void main(String[] args) {
Frame frame = new Frame("5x5 Grid Layout Demo");
frame.setSize(400, 400);
frame.setLayout(new GridLayout(5,5));
Button b1=new Button("1");
Button b2=new Button("2");
Button b3=new Button("3");
Button b4=new Button("4");
Button b5=new Button("5");
Button b6=new Button("6");
Button b7=new Button("7");
Button b8=new Button("8");
Button b9=new Button("9");
Button b10=new Button("10");
Button b11=new Button("11");
Button b12=new Button("12");
Button b13=new Button("13");
Button b14=new Button("14");
Button b15=new Button("15");
Button b16=new Button("16");
Button b17=new Button("17");
Button b18=new Button("18");
Button b19=new Button("19");
Button b20=new Button("20");
Button b21=new Button("21");
Button b22=new Button("22");
Button b23=new Button("23");
Button b24=new Button("24");
Button b25=new Button("25");
frame.setVisible(true);
Name of Student: Ekambe Ganesh Roll No.: 53
Experiment No.: 03 DOS:

frame.add(b1);
frame.add(b2);
frame.add(b3);
frame.add(b4);
frame.add(b5);
frame.add(b6);
frame.add(b7);
frame.add(b8);
frame.add(b9);
frame.add(b10);
frame.add(b11);
frame.add(b12);
frame.add(b13);
frame.add(b14);
frame.add(b15);
frame.add(b16);
frame.add(b17);
frame.add(b18);
frame.add(b19);
frame.add(b20);
frame.add(b21);
frame.add(b22);
frame.add(b23);
frame.add(b24);
frame.add(b25);
}
}
Name of Student: Ekambe Ganesh Roll No.: 53
Experiment No.: 03 DOS:

Output
Name of Student: Ekambe Ganesh Roll No.: 53
Experiment No.: 03 DOS:

2. Write a program to display The Number on Button from 0 to 9.

import java.awt.*;
public class Pr3 {
public static void main(String[] args) {
Frame frame = new Frame("0 To 9 Number on button ");
frame.setSize(400, 400);
frame.setLayout(new GridLayout(5,5));
Button b1=new Button("1");
Button b2=new Button("2");
Button b3=new Button("3");
Button b4=new Button("4");
Button b5=new Button("5");
Button b6=new Button("6");
Button b7=new Button("7");
Button b8=new Button("8");
Button b9=new Button("9");
Button b10=new Button("0");
frame.setVisible(true);
frame.add(b10);
frame.add(b1);
frame.add(b2);
frame.add(b3);
frame.add(b4);
frame.add(b5);
frame.add(b6);
frame.add(b7);
frame.add(b8);
frame.add(b9);
}
}
Name of Student: Ekambe Ganesh Roll No.: 53
Experiment No.: 03 DOS:

Output
Name of Student: Ekambe Ganesh Roll No.: 53
Experiment No.: 03 DOS:

Exercise
1.
import java.awt.*;

public class Pr3Ex1

public static void main(String[] args) {

Frame fr= new Frame("GridLayout Demo");

fr.setSize(500, 300);

fr.setLayout(new GridLayout(3, 2, 10, 10));

fr.setVisible(true);

Button b1=new Button("Button 1");

Button b2=new Button("Button 2");

Button b3=new Button("Button 3");

Button b4=new Button("Button 4");

Button b5=new Button("Button 5");

fr.add(b1);

fr.add(b2);

fr.add(b3);

fr.add(b4);

fr.add(b5);

Output
Name of Student: Ekambe Ganesh Roll No.: 53
Experiment No.: 03 DOS:
Name of Student: Ekambe Ganesh Roll No.: 53
Experiment No.: 03 DOS:

2.
import java.awt.*;

public class Pr3Ex2 extends Frame {


private Button btnNorth, btnSouth, btnCenter, btnEast,
btnWest;
public Pr3Ex2()
{
setLayout(new BorderLayout(3, 3));
btnNorth = new Button("NORTH") ;
add(btnNorth, BorderLayout.NORTH);
btnSouth = new Button("SOUTH");
add( btnSouth, BorderLayout.SOUTH);
btnCenter = new Button( "CENTER");
add(btnCenter, BorderLayout.CENTER);
btnEast = new Button( "EAST");
add(btnEast, BorderLayout . EAST);
btnWest = new Button("WEST");
add(btnWest, BorderLayout.WEST);
setTitle( "Border Layout Demo");
setSize(280, 150);
setVisible(true);
Name of Student: Ekambe Ganesh Roll No.: 53
Experiment No.: 03 DOS:

}
public static void main(String[] args) {
new Pr3Ex2();
}
}

Output

You might also like