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

Ajp Practical 3

The document contains code for two Java applet programs. The first program uses a GridLayout to display numbered buttons in a 3x2 grid. The second program uses a BorderLayout to add labeled buttons and a text area to the applet window in the corresponding BorderLayout positions (e.g. button labeled "NORTH" added to the NORTH position).

Uploaded by

Mr. Omkar
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)
70 views4 pages

Ajp Practical 3

The document contains code for two Java applet programs. The first program uses a GridLayout to display numbered buttons in a 3x2 grid. The second program uses a BorderLayout to add labeled buttons and a text area to the applet window in the corresponding BorderLayout positions (e.g. button labeled "NORTH" added to the NORTH position).

Uploaded by

Mr. Omkar
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
Q1.Wite a program to generate the following output.
import java.applet.*;
import java.awt.*;
/*<applet code=gdemo.class width=500 height=500></applet>*/
public class gdemo extends Applet
{
public void init()
{
GridLayout g=new GridLayout(3,2,10,10);
setLayout(g);
for(int i=0;i<2;i++)
{
for(int j=0;j<3;j++)
{
int k=i*3+j;
if(k>0)
{
add(new Button(" "+k));
}
}
}
}
}
Output:
Practical No.3
Q2.Wite a program to generate the following output using Border Layout.
import java.applet.*;
import java.awt.*;
/*<applet code=gademo.class width=500 height=500></applet>*/
public class gademo extends Applet
{
public void init()
{
TextArea ta;
Button b1,b2,b3,b4,b5;
BorderLayout b=new BorderLayout();
setLayout(b);
b1=new Button("NORTH");
b2=new Button("SOUTH");
b3=new Button("WEST");
b4=new Button("EAST");
b5=new Button("CENTER");
ta=new TextArea();
add(b1,BorderLayout.NORTH);
add(b2,BorderLayout.SOUTH);
add(b3,BorderLayout.WEST);
add(b4,BorderLayout.EAST);
add(b5,BorderLayout.CENTER);
}
}
Output:

You might also like