examples
Class Example7

java.lang.Object
  extended by examples.Example7

public class Example7
extends java.lang.Object

A simple example of CellGrid. At the top is a regular grid in which all the elements of the grid are specified to be panels. Below it is a grid in which some of the elements are blank spaces. The example illustrates the use of both of the two createCellGrid methods described below.



        public static int NUMROWS=5;
        public static int NUMCOLUMNS=6;
        public Example7()
        {

                JFrame frame=new JFrame();
                frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                Container container =frame.getContentPane();
                frame.setBounds(100,100,400,600);
                Color topColor=new Color(200,200,255);
                Color bottomColor=new Color(255,200,200);


                // Component cells for the top regular grid.
                ComponentCell cells[][]=new ComponentCell[NUMROWS][NUMCOLUMNS];
                for(int i=0;i<NUMROWS;i++)
                        for(int j=0;j<NUMCOLUMNS;j++)
                        {
                                JPanel p=new JPanel();
                                p.setBorder(
                                 BorderFactory.createLoweredBevelBorder());
                                p.setBackground(topColor);
                                cells[i][j]=new ComponentCell(p);
                        }

                // Create the top grid
                CellGrid topGrid=
                        CellGrid.createCellGrid(cells);


                // Component cells for the bottom grid.
                int rowIndices[]={0,0,2,1,4,3};
                int columnIndices[]={2,1,4,3,0,2};
                int n=rowIndices.length;
                ComponentCell bottomCells[]=new ComponentCell[n];
                for(int i=0;i<n;i++)
                {
                        JPanel p=new JPanel();
                        p.setBackground(bottomColor);
                                p.setBorder(
                                 BorderFactory.createRaisedBevelBorder());
                        bottomCells[i]=new ComponentCell(p);
                }
                // Create the bottom grid
                CellGrid bottomGrid=CellGrid.createCellGrid(bottomCells,rowIndices,columnIndices);

                // Put the two grids in a column and create the layout manager.
                Column column=new Column(topGrid,bottomGrid);
                column.createLayout(container);


                frame.pack();
                frame.setVisible(true);

        }


Field Summary
static int NUMCOLUMNS
           
static int NUMROWS
           
 
Constructor Summary
Example7()
           
 
Method Summary
static void main(java.lang.String[] args)
           
static void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NUMROWS

public static int NUMROWS

NUMCOLUMNS

public static int NUMCOLUMNS
Constructor Detail

Example7

public Example7()
Method Detail

main

public static void main(java.lang.String[] args)

run

public static void run()