src/main/java/de/uapcore/sudoku/Sudoku.java

Wed, 26 Aug 2020 19:09:07 +0200

author
Mike Becker <universe@uap-core.de>
date
Wed, 26 Aug 2020 19:09:07 +0200
changeset 25
569220009c54
parent 18
530f60fa3dc9
permissions
-rw-r--r--

fixes wrong call of assertEquals()

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
9
576e7a2861ae converts to maven project
Mike Becker <universe@uap-core.de>
parents: 3
diff changeset
29 import javax.swing.*;
576e7a2861ae converts to maven project
Mike Becker <universe@uap-core.de>
parents: 3
diff changeset
30 import java.awt.*;
1
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 /**
10
369903afbb29 adds more javadoc
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
33 * Main class of the application.
1
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 */
2
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents: 1
diff changeset
35 public final class Sudoku extends JFrame {
10
369903afbb29 adds more javadoc
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
36
369903afbb29 adds more javadoc
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
37 /**
369903afbb29 adds more javadoc
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
38 * Constructs the Sudoku main window.
369903afbb29 adds more javadoc
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
39 */
1
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40 public Sudoku() {
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
41 super("Sudoku");
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
42
2
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents: 1
diff changeset
43 Field f = new Field();
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents: 1
diff changeset
44 ActionHandler h = new ActionHandler(f);
18
530f60fa3dc9 the MainMenu IS a JMenuBar
Mike Becker <universe@uap-core.de>
parents: 15
diff changeset
45 setJMenuBar(new MainMenu(h));
2
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents: 1
diff changeset
46
3
ed931970b4ac added license and main menu
Mike Becker <universe@uap-core.de>
parents: 2
diff changeset
47 Container content = getContentPane();
1
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
48
3
ed931970b4ac added license and main menu
Mike Becker <universe@uap-core.de>
parents: 2
diff changeset
49 content.setLayout(new GridBagLayout());
1
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
50 GridBagConstraints c = new GridBagConstraints();
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
51 c.insets = new Insets(20, 20, 20, 20);
2
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents: 1
diff changeset
52 c.fill = GridBagConstraints.HORIZONTAL;
1
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
53
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
54 c.gridx = 0; c.gridy = 0;
3
ed931970b4ac added license and main menu
Mike Becker <universe@uap-core.de>
parents: 2
diff changeset
55 content.add(f, c);
2
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents: 1
diff changeset
56 c.gridy++;
3
ed931970b4ac added license and main menu
Mike Becker <universe@uap-core.de>
parents: 2
diff changeset
57 content.add(new ButtonPanel(h), c);
1
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
58
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
59 pack();
3
ed931970b4ac added license and main menu
Mike Becker <universe@uap-core.de>
parents: 2
diff changeset
60 content.setBackground(Color.WHITE);
1
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
61 setLocationByPlatform(true);
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
62 setDefaultCloseOperation(EXIT_ON_CLOSE);
15
fea6eaa0d520 fix: window cannot get smaller than the field
Mike Becker <universe@uap-core.de>
parents: 10
diff changeset
63 setMinimumSize(getSize());
1
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
64 }
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 /**
10
369903afbb29 adds more javadoc
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
67 * Main method starting the Sudoku solver.
369903afbb29 adds more javadoc
Mike Becker <universe@uap-core.de>
parents: 9
diff changeset
68 *
1
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
69 * @param args the command line arguments
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
70 */
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
71 public static void main(String[] args) {
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
72 new Sudoku().setVisible(true);
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
73 }
f1d7de36b01e init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff changeset
74 }

mercurial