/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author STUDENT */ // Fig. 13.26: GridLayoutDemo.java // Demonstrating GridLayout. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class GridLayoutDemo extends JFrame implements ActionListener { private JButton buttons[]; private final String names[]= {"ones","two","three","four","five","six"}; private boolean toggle=true; private Container container; private GridLayout grid1, grid2; //set up GUI public GridLayoutDemo() { super("GridLayout Demo"); //set up layout grid1=new GridLayout(2,3,5,5); grid2=new GridLayout(3,2); //get content pane and set its layout container=getContentPane(); container.setLayout(grid1); //create and add buttons buttons=new JButton[names.length]; for (int count=0;count