import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JPanel;
 
 
public class Board extends JPanel  { 
	 private JButton[][] buttons = new JButton[5][5];
 
  public Board() {
	  super(new GridLayout(5,5));     
        
       for(int row=0; row<buttons.length; row++){
           for(int col=0; col<buttons.length; col++){
           
             JButton b = new JButton ("("+row+","+col+")");      
             this.buttons[row][col] = b;
             this.add(b);
           
           }
       }      
     
   }
 
   public JButton getSpot(int x, int y) {
       return buttons[x][y];
   }
 
}

@@ -1,16 +1,40 @@
+%0Aimport java.awt.Color;%0A
 import java.awt.
@@ -60,21 +60,141 @@
 java
-x.swing.JButt
+.awt.image.BufferedImage;%0Aimport java.io.File;%0Aimport java.io.IOException;%0A %0Aimport javax.imageio.ImageIO;%0Aimport javax.swing.ImageIc
 on;%0A
@@ -222,18 +222,16 @@
 anel;%0A %0A
- %0A
 public c
@@ -265,62 +265,29 @@
 %7B %0A%09
- private JButton%5B%5D%5B%5D buttons = new JButton%5B5%5D%5B5%5D
+Tile%5B%5D%5B%5D buttons
 ;%0A %0A
-  
+%09
 publ
@@ -299,15 +299,32 @@
 ard(
+int rows, int cols
 ) %7B%0A%09
-  
+%09
 supe
@@ -344,36 +344,278 @@
 out(
-5,5));     %0A        %0A       
+rows, cols));%0A%09%09buttons = new Tile%5Brows%5D%5Bcols%5D;%0A%09%09BufferedImage puzzle = null;%0A%09%09try %7B%0A%09%09%09puzzle = ImageIO.read(new File(%22Images/pic1.jpg%22));%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09e.printStackTrace();%0A%09%09%7D%0A%09%09int width = puzzle.getWidth();%0A%09%09int height = puzzle.getHeight();%0A %0A%09%09
 for(
@@ -625,51 +625,37 @@
  row
-=
+ = 
 0; row
-%3Cbuttons.length; row++)%7B%0A           
+ %3C rows; row++)%7B%0A%09%09%09
 for(
@@ -665,314 +665,621 @@
  col
-=
+ = 
 0; col
-%3Cbuttons.length; col++)%7B%0A           %0A             JButton b = new JButton (%22(%22+row+%22,%22+col+%22)%22);      %0A             this.buttons%5Brow%5D%5Bcol%5D = b;%0A             this.add(b);%0A           %0A           %7D%0A       %7D      %0A     %0A   %7D%0A %0A   public JButton getSpot(int x, int y) %7B%0A       return buttons%5Bx%5D%5By%5D;%0A   
+ %3C cols; col++)%7B%0A%09%09%09%09Tile tile = new Tile(row, col);%09%09%09%09%0A%09%09%09%09buttons%5Brow%5D%5Bcol%5D = tile;%0A%09%09%09%09if (!(row == 0 && col == 0)) %7B%0A%09%09%09%09%09BufferedImage cropped = puzzle.getSubimage(%0A%09%09%09%09%09%09%09col * width / cols, row * height / rows, width / cols, height / rows);%0A%09%09%09%09%09tile.setIcon(new ImageIcon(cropped));%0A%09%09%09%09%7D%0A%09%09%09%09tile.setBackground(Color.GRAY);%0A%09%09%09%09//tile.addActionListener(new TileListener());%0A%09%09%09%09this.add(tile);%0A%09%09%09%7D%0A%09%09%7D      %0A%09%7D%0A%09%0A%09public void checkIfComplete() %7B%0A%09%09for (Tile%5B%5D tiles : buttons) %7B%0A%09%09%09for (Tile tile : tiles) %7B%0A%09%09%09%09if (!tile.hasRightImage()) %7B%0A%09%09%09%09%09return;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A//%09%09Window.endGame();%0A%09
 %7D%0A %0A%7D
-%0A

Implement split image board with a variable number of tiles.