Write a program which will load an image file and then display a sliding-piece puzzle based on that image.
Components in the main frame:
a.) button for "Exit"
.) button for "New image"
c.) button for "Play/Pause"
.) JPanel for displaying the puzzle
c.) Label showing elapsed play time
d.) Label showing number of moves
e.) Label showing the number of pieces still not in the co
ect place
Public Static Constant:
The number of rows (which will also be the number of columns)
Your JErame constructor should build the GUI and set up listeners.
e user to select an image file. That
se a JFileChooser to appear to allow th
the buttons that make up the puzzle.
The "New image" button should cau
hich are used when constructing
image should be cropped into the pieces W
This smart button should know where it 1S,
n representing one piece of the puzzle.
how to swap its Image with the image on
Create a subclass of JButto
laying is the co
ect image, and knows
know if the image it is disp
another smart button.
p the timing, and when in "Pause" mode should hide the puzzle by
The Play/Pause button should start/sto
displaying the original image.
" the puzzle pieces, be able to know if the puzzle is
h a way that the puzzle is still solvable.
The image should be scrambled in suc
s the first move, suspended when in the "pause" mode, and stopped
Timing should begin when the user make
when the puzzle 1s solved.
mation will be given in class.
More info