Q:

Java - Grid Layout using Frame Demo

0

This Program is used to demonstrate the Grid Layout.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

// Grid Layout

import java.awt.*;
import java.awt.event.*;
import java.applet.*;

public class grid extends Frame
{
Button b1,b2,b3,b4;

grid()
{
setLayout(new GridLayout(3,2));

b1 = new Button("one");
b2 = new Button("two");
b3 = new Button("three");
b4 = new Button("four");

add(b1); add(b2); add(b3); add(b4);

addWindowListener(new w());
}

class w extends WindowAdapter
{ 
public void windowClosing(WindowEvent we)
{
System.exit(0);
}
}

public static void main(String arg[])
{
grid ff = new grid();
ff.show();
ff.setBounds(0,0,300,300);
}
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now