Now I need to write a 8-puzzle game, which looks [like this]
The instructor asked us to write three different classes, which are Piece.java, EightPuzzle.java, and EightPuzzlePanel.java. As you can see, Piece.java represents each individual piece like "1", "2" in this eight puzzle board; EightPuzzle.java represents the the game board to hold these 9 pieces/buttons. EightPuzzlePanel.java is the GUI stuff.
So my question is, since we need to create a Piece[][] piece = new Piece[][], a 2D array, and we also need to arrange these piece on the board. I thought I could create 9 JButtons and put the 2D array in link with the 9 JButtons (or there have a better way to sort the 2D-array), but I don't know how to do that.
Also the buttons need to be controlled by both mouse and keyboard. This is another challenge for me.