0% found this document useful (0 votes)
25 views

Ajp PR3

Uploaded by

Vighnesh Pote
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)
25 views

Ajp PR3

Uploaded by

Vighnesh Pote
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/ 4

Practical No.

3
Name: Pote Vighnesh Sandip Class: CO5I
Roll No: Batch: C

Title: Write a program to design simple calculator with the use of Grid Layout.

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


Program:
package Practical3;

import java.awt.*;
public class PR3_1
{
public static void main (String args[])
{
Frame f = new Frame();
f.setSize(300,450);
f.setVisible(true);
GridLayout g = new GridLayout(5,5);
for (int i=1; i<=25; i++)
{
Button b = new Button(""+i);
f.add(b);
}
f.setLayout(g);
}
}

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

Program:
package Practical3;

import java.awt.*;
public class PR3_2
{
public static void main (String args[])
{
Frame f = new Frame();
f.setSize(500,500);
f.setVisible(true);
GridLayout g = new GridLayout(5,2);
for (int i=0; i<=9; i++)
{
Button b = new Button(""+i);
f.add(b);
}
f.setLayout(g);
}
}

Output:
3. Write a program to generate the following Output.

Program:
package Practical3;
import java.awt.*;
public class PR3_3
{
public static void main (String args[])
{
Frame f = new Frame("GridLayout Demo");
f.setSize(500,500);
f.setVisible(true);
GridLayout g = new GridLayout(3,2,15,15);
for(int i=1; i<=5; i++)
{
Button b = new Button("Button"+i);
f.add(b);
}
f.setLayout(g);
}
}

Output:
4. Write a program to generate following Output using BorderLayout.

Program:
package Practical3;

import java.awt.*;
public class PR3_4
{
public static void main (String args[])
{
Frame f = new Frame();
BorderLayout b=new BorderLayout();
Button b1 = new Button("North");
Button b2 = new Button("West");
Button b3 = new Button("East");
Button b4 = new Button("South");
Button b5 = new Button("Center");
f.add(b1,BorderLayout.NORTH);
f.add(b2,BorderLayout.WEST);
f.add(b3,BorderLayout.EAST);
f.add(b4,BorderLayout.SOUTH);
f.add(b5,BorderLayout.CENTER);
f.setSize(370,200);
f.setVisible(true);
}
}

Output:

You might also like