question: private void refreshMapButtons ( ) { panMapButtons . removeAll ( ) ; panMapButtons . setLayout ( new GridLayout ( mapSettings . getMapHeight ( ) , mapSettings . getMapWidth ( ) ) ) ; for ( int i = 0 ; i < mapSettings . getMapHeight ( ) ; i ++ ) { for ( int j = 0 ; j < mapSettings . getMapWidth ( ) ; j ++ ) { JButton button = new JButton ( Integer . toString ( ( i * mapSettings . getMapWidth ( ) ) + j ) ) ; button . addActionListener ( this ) ; panMapButtons . add ( button ) ; } } scrMapButtons . validate ( ) ; labBoardsAvailable . setText ( mapSettings . getBoardWidth ( ) + "x" + mapSettings . getBoardHeight ( ) + " " + Messages . getString ( "BoardSelectionDialog.mapsAvailable" ) ) ; comboMapSizes . removeActionListener ( this ) ; int items = comboMapSizes . getItemCount ( ) ; boolean mapSizeSelected = false ; for ( int i = 0 ; i < ( items - 1 ) ; i ++ ) { BoardDimensions size = ( BoardDimensions ) comboMapSizes . getItemAt ( i ) ; if ( ( size . width ( ) == mapSettings . getBoardWidth ( ) ) && ( size . height ( ) == mapSettings . getBoardHeight ( ) ) ) { comboMapSizes . setSelectedIndex ( i ) ; mapSizeSelected = true ; } } if ( ! mapSizeSelected ) { comboMapSizes . setSelectedIndex ( items - 1 ) ; } comboMapSizes . addActionListener ( this ) ; }
target:  Fills the Map Buttons scroll pane with the appropriate amount of buttons in the appropriate layout