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.
Since this is homework I will not go into much detail, but this is how I would go about it:
Pieceextends theJButtonclass. ThePieceobject takes the text to display and also the location of the image you would like it to render. You should be able to find plenty of examples online on how to add an image to aJButton.EightPuzzleextend theJPanelclass and also use the Grid Layout to render the Pieces neatly in a grid. This class takes on a 2D array ofPieceobjects which it will then render.EightPuzzlePanelalso extend theJPanelclass. This class takes in another JPanel (EightPuzzle) and appends any other buttons you might need.JFrameand then I append theEightPuzzlePanelto it (which should in turn contain the other panel with the other buttons).