Fri, 01 Feb 2013 10:18:47 +0100
removed completeness test - the solver automatically returns false when the field is incomplete
3
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
1 | /* |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
2 | * Copyright 2013 Mike Becker. All rights reserved. |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
3 | * |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
4 | * Redistribution and use in source and binary forms, with or without |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
5 | * modification, are permitted provided that the following conditions are met: |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
6 | * |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
7 | * 1. Redistributions of source code must retain the above copyright |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
8 | * notice, this list of conditions and the following disclaimer. |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
9 | * |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
10 | * 2. Redistributions in binary form must reproduce the above copyright |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
11 | * notice, this list of conditions and the following disclaimer in the |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
12 | * documentation and/or other materials provided with the distribution. |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
13 | * |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
15 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
16 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
17 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
18 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
19 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
20 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
21 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
22 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
23 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
24 | * POSSIBILITY OF SUCH DAMAGE. |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
25 | */ |
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
26 | |
1
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
27 | package de.uapcore.sudoku; |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
28 | |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
29 | import java.awt.Color; |
3
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
30 | import java.awt.Container; |
1
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
31 | import java.awt.GridBagConstraints; |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
32 | import java.awt.GridBagLayout; |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
33 | import java.awt.Insets; |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
34 | import javax.swing.JFrame; |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
35 | |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
36 | /** |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
37 | * |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
38 | * @author mike |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
39 | */ |
2 | 40 | public final class Sudoku extends JFrame { |
1
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
41 | |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
42 | public Sudoku() { |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
43 | super("Sudoku"); |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
44 | |
2 | 45 | Field f = new Field(); |
46 | ActionHandler h = new ActionHandler(f); | |
3
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
47 | setJMenuBar(new MainMenu(h).getMenuBar()); |
2 | 48 | |
3
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
49 | Container content = getContentPane(); |
1
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
50 | |
3
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
51 | content.setLayout(new GridBagLayout()); |
1
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
52 | GridBagConstraints c = new GridBagConstraints(); |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
53 | c.insets = new Insets(20, 20, 20, 20); |
2 | 54 | c.fill = GridBagConstraints.HORIZONTAL; |
1
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
55 | |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
56 | c.gridx = 0; c.gridy = 0; |
3
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
57 | content.add(f, c); |
2 | 58 | c.gridy++; |
3
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
59 | content.add(new ButtonPanel(h), c); |
1
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
60 | |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
61 | pack(); |
3
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
62 | content.setBackground(Color.WHITE); |
1
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
63 | setLocationByPlatform(true); |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
64 | setDefaultCloseOperation(EXIT_ON_CLOSE); |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
65 | } |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
66 | |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
67 | /** |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
68 | * @param args the command line arguments |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
69 | */ |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
70 | public static void main(String[] args) { |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
71 | new Sudoku().setVisible(true); |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
72 | } |
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
73 | } |