void addFillComponents ( Container panel , int [ ] cols , int [ ] rows ) { Dimension filler = new Dimension ( 10 , 10 ) ; boolean filled_cell_11 = false ; CellConstraints cc = new CellConstraints ( ) ; if ( cols . length > 0 && rows . length > 0 ) { if ( cols [ 0 ] == 1 && rows [ 0 ] == 1 ) { /** add a rigid area */ panel . add ( Box . createRigidArea ( filler ) , cc . xy ( 1 , 1 ) ) ; filled_cell_11 = true ; } } for ( int index = 0 ; index < cols . length ; index ++ ) { if ( cols [ index ] == 1 && filled_cell_11 ) { continue ; } panel . add ( Box . createRigidArea ( filler ) , cc . xy ( cols [ index ] , 1 ) ) ; } for ( int index = 0 ; index < rows . length ; index ++ ) { if ( rows [ index ] == 1 && filled_cell_11 ) { continue ; } panel . add ( Box . createRigidArea ( filler ) , cc . xy ( 1 , rows [ index ] ) ) ; } }
Adds fill components to empty cells in the first row and first column of the grid . This ensures that the grid spacing will be the same as shown in the designer .