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

Practical 3 Java (Print)

The document contains a Java applet code for a GridLayout demonstration. It initializes a 4x4 grid layout and adds buttons labeled with numbers to the applet. The applet is designed to display a grid of buttons when executed.
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)
7 views2 pages

Practical 3 Java (Print)

The document contains a Java applet code for a GridLayout demonstration. It initializes a 4x4 grid layout and adds buttons labeled with numbers to the applet. The applet is designed to display a grid of buttons when executed.
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/ 2

Practical 3

Input :

import java.awt.*;

import java.applet.*;

public class GridLayoutDemo extends Applet

/*<applet code = "GridLayoutDemo.class" width = "300" height = "300">

</applet.

*/

static final int n = 4;

public void init()

setLayout(new GridLayout(n,n));

setFont(new Font("SansSerif",Font.BOLD,24));

for( int i = 0;i<n;i++)

for(int j = 0;j<n;j++)

int k = i*n+j;

if(k>0)

add(new Button(""+k));

}
Practical 3

Output :

You might also like