src/de/uapcore/sudoku/ButtonPanel.java

Thu, 31 Jan 2013 18:44:44 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 31 Jan 2013 18:44:44 +0100
changeset 7
2c0a2766461c
parent 3
ed931970b4ac
permissions
-rw-r--r--

added solving algorithm

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
2
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
27 package de.uapcore.sudoku;
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
28
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
29 import java.awt.Color;
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
30 import java.awt.GridBagConstraints;
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
31 import java.awt.GridBagLayout;
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
32 import java.awt.Insets;
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
33 import javax.swing.JButton;
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
34 import javax.swing.JPanel;
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
35
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
36 /**
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
37 *
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
38 * @author mike
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
39 */
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
40 public final class ButtonPanel extends JPanel {
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
41
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
42 private JButton save, check, solve;
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
43
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
44 public ButtonPanel(ActionHandler l) {
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
45 setLayout(new GridBagLayout());
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
46
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
47 GridBagConstraints c = new GridBagConstraints();
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
48 c.insets = new Insets(10, 10, 10, 10);
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
49 c.fill = GridBagConstraints.HORIZONTAL;
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
50 c.weightx = 1;
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
51
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
52 c.gridx = 0;
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
53 c.gridy = 0;
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
54 save = new JButton("Speichern");
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
55 add(save, c);
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
56 c.gridx++;
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
57 check = new JButton("Prüfen");
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
58 add(check, c);
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
59 solve = new JButton("Lösen");
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
60 c.gridx++;
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
61 add(solve, c);
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
62
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
63 save.setActionCommand(ActionHandler.SAVE);
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
64 save.addActionListener(l);
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
65 check.setActionCommand(ActionHandler.CHECK);
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
66 check.addActionListener(l);
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
67 solve.setActionCommand(ActionHandler.SOLVE);
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
68 solve.addActionListener(l);
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
69
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
70 setBackground(Color.WHITE);
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
71 }
5179eff8a9b6 check functions
Mike Becker <universe@uap-core.de>
parents:
diff changeset
72 }

mercurial