0% found this document useful (0 votes)
20 views4 pages

Practical No. 3

Uploaded by

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

Practical No. 3

Uploaded by

ganeshkumbhar638
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Q1. Write a program to generate following output.

Code :

import java.awt.*;

public class P3e2 extends Frame {


P3e2(){
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");
add(b1);
add(b2);
add(b3);
add(b4);
add(b5);
setLayout(new GridLayout(3,2,10,10));
setVisible(true);
setSize(450,250);
}
public static void main(String[] args) {
new P3e2();
}
}
Q2. Write a program to generate following output using Border Layout.

Code :
import java.awt.*;

public class P3e1 extends Frame {


public P3e1() {
Button b1 = new Button("NORTH");
Button b2 = new Button("EAST");
Button b3 = new Button("WEST");
Button b4 = new Button("CENTER");
Button b5 = new Button("SOUTH");
add(b1);
add(b2);
add(b3);
add(b4);
add(b5);
add(b1,BorderLayout.NORTH);
add(b2,BorderLayout.EAST);
add(b3,BorderLayout.WEST);
add(b4,BorderLayout.CENTER);
add(b5,BorderLayout.SOUTH);
setVisible(true);
setSize(500,500);
}
public static void main(String[] args) {
new P3e1();
}
}
Q1. Write java program to Demonstrate Grid 5*5.

import java.awt.*;

public class P3b1 extends Frame {


P3b1() {
for (int i = 1; i <= 25; i++) {
add(new Button("Button " + i));
}
setVisible(true);
setSize(400, 400);
setLayout(new GridLayout(5, 5));
}

public static void main(String[] args) {


new P3b1();
}
}

Output :
Q2. Write a program to display the number on Button form 0 to 9.
import java.awt.*;

public class P3b2 extends Frame {


P3b2() {
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 b0 = new Button("0");
add(b1);
add(b2);
add(b3);
add(b4);
add(b5);
add(b6);
add(b7);
add(b8);
add(b9);
add(b0);
setVisible(true);
setSize(600, 150);
setLayout(new GridLayout(2, 5,5,8));
}
public static void main(String[] args) {
new P3b2();
}
}

Output :

You might also like