Login    New User    Forgot Password    Help      

Grid Layout

Java Tutorials

Example

// Grid Layout
import java.awt.*;
import java.applet.*;
/*
<applet code="control12" width=250 height=300>

</applet>
*/

public class control12 extends Applet

{
static final int n=4;
int i,j,k=1;

public void init()

{
setLayout(new GridLayout(n,n));
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
add(new Button(" " +k));
k++;
}
}
}
}

Output

Output in applet

Java Tutorials