0. Go to http://www.cs.miami.edu/~vjm/csc120/prog12/Sudoku.html To create a test board, click test. (My browser seems to be a little confused about where my mouse is clicking so you may have to click close to the right edge of the button. I don't know what's the deal with that.) Click solve. Click clear. 1. Create SudokuGUI. In your prog12 directory, you will also need a copy of Board.java, a working implementation of Board (I am using VBoard here, but you can use MyBoard), and a working Sudoku.java. import javax.swing.*; import java.awt.*; import java.awt.event.*; public class SudokuGUI extends JApplet implements ActionListener { private JPanel panel; private JButton solveButton, clearButton, testButton; private JTextField[] grid = new JTextField[81]; private Board board = new VBoard(); public SudokuGUI () { In the constructor: a. Create a ``solve'' button (in solveButton) and make ``this'' its action listener. Ditto clear and test. b. Create a north panel which uses flow layout, and add the three buttons to it. c. Create a center panel with a 9 by 9 grid layout. Initialize the entries of grid to single-space text fields (new TextField(1)) and add each of them to the center panel. d. Make panel (the private variable above) a new panel with a border layout, and add north and center to it. 2. In order for this to display on a web page, also create a method init(): public void init () { setLayout(new FlowLayout()); add(panel); } What this means is center the panel of buttons and text fields on the specified portion of the web page and show it. Create a main so you can run SudokuGUI from the command prompt instead of in a web page: public static void main (String[] args) { SudokuGUI gui = new SudokuGUI(); JFrame frame = new JFrame("Sudoku Solver"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(gui.panel); frame.pack(); frame.setVisible(true); } This creates a SudokuGUI and adds its panel to the frame. 3. For now, just have actionPerformed use JOptionPane.showMessageDialog to say which button was pushed. The first if statement shows how to tell that the solveButton was pushed. public void actionPerformed (ActionEvent event) { if (event.getSource() == solveButton) { 4. Create a file Sudoku.html: If you are in the lab, you can run it from a command prompt: java SudokuGUI You can also test it as a web page using appletviewer: appletviewer Sudoku.html If you are at home, neither of these will work because they use graphics, but you CAN test the web page version. cp *.class *.html ../public_html Then in your browser visit http://www.cs.miami.edu/students/????120/Sudoku.html where ????120 is your course account. NOTE: if you make a change, you have do the cp again, SHUT DOWN your browser, and then load again. If you don't shut down, the browser may not load your changes. The reload button isn't good enough. 5. Now we have to do the equivalent of loading and printing. a. Write display2board which reads each text field, and if it has a number from 1 to 9, puts it into the board. I would suggest checking if the length of the text is 1 and if the first (and only) character is a digit in the range from 1 to 9. private void display2board () { b. Write board2display which looks at each position in board. If it has only one value, write that value into the appropriate text field. By the way, if val==7, then "" + val == "7". That's a quick way to turn it into a string. Otherwise, put "" into the text field. c. Writing a clear method is easy: private void clear () { board = new VBoard(); board2display(); } d. The test method can use our favorite test puzzle, write it into the board using a loop, and then call board2display to display it. private void test () { String puzzle = "1.......2.9.4...5...6...7...5.9.3.......7.......85..4.7.....6...3...9.8...2.....1"; NOTE: call clear() at the top of test() to make sure the board is blank before you load the test problem. 6. Modify actionPerformed to call clear() and test() when appropriate. For solve, just make sure that display2board() works: display2board(); board2display(); Click clear. Click test. Click solve. The numbers should stay there. Change some numbers and click solve again. They should stay there. 7. Finally, modify the solve portion of actionPerformed. a. Initialize board to a fresh new board. b. Call display2board to load it from the display. c. Call Sudoku.solve to solve it. d. If the solution is null, then say so. e. If the solution is not null, then set board to the solution, call board2display() to display it, and tell the user that the Sudoku is solved.