Tuesday, September 30, 2008

GRIDLAYOUT

New GridLayout(int rows, int cols)
/* *
Output:
* */
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class MainClass extends JPanel
{
public MainClass()
{
super(new GridLayout(2,2));
add(new JButton("w w w1"));
add(new JButton("w w w2" ));
add(new JButton("w w w3" ));
add(new JButton("www4" ));
}
public static void main(String[] args)
{
JFrame frame = new JFrame();
frame.getContentPane().add(new MainClass());
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200,200);
frame.setVisible(true);
}
}

No comments: