Mon, 27 Jul 2020 12:08:23 +0200
fix: window cannot get smaller than the field
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 | 29 | import javax.swing.*; |
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 | 33 | * Main class of the application. |
1
f1d7de36b01e
init project + editable sudoku field
Mike Becker <universe@uap-core.de>
parents:
diff
changeset
|
34 | */ |
2 | 35 | public final class Sudoku extends JFrame { |
10 | 36 | |
37 | /** | |
38 | * Constructs the Sudoku main window. | |
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 | 43 | Field f = new Field(); |
44 | ActionHandler h = new ActionHandler(f); | |
3
ed931970b4ac
added license and main menu
Mike Becker <universe@uap-core.de>
parents:
2
diff
changeset
|
45 | setJMenuBar(new MainMenu(h).getMenuBar()); |
2 | 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 | 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 | 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 | 67 | * Main method starting the Sudoku solver. |
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 | } |