I made a program to change grid layout1 to grid layout2 but its not working(it is not showing the grid layout). Where is the error?


package pratt;

import java.awt.Container;
import java.awt.GridLayout;
import java.awt.Point;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextArea;

public class Project2 extends JFrame implements ActionListener {

private boolean toggle=true;
private JButton[] buttons;
private static String names[] = { "one", "two", "three", "four", "five",
"six" };
private Container container;
private GridLayout gl1;
private GridLayout gl2;

public Project2() {

gl1 = new GridLayout(3, 2, 5, 5);
gl2 = new GridLayout(2, 3);
container = getContentPane();
setLayout(gl1);
buttons = new JButton[names.length];
for (int i = 0; i < names.length; i++) {
buttons = new JButton(names);
buttons.addActionListener( this );

}


}

public void actionPerformed(ActionEvent event){
if(toggle)
setLayout(gl2);
else
setLayout(gl1);
toggle=!toggle;

container.validate();



}


}