Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ElforL committed Jun 20, 2021
0 parents commit 3dde5b8
Show file tree
Hide file tree
Showing 17 changed files with 558 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
28 changes: 28 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Sudoku Solver</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1624184402136</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
12 changes: 12 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Binary file added Sudoku Solver.jar
Binary file not shown.
Binary file added bin/GUI2$1.class
Binary file not shown.
Binary file added bin/GUI2$2.class
Binary file not shown.
Binary file added bin/GUI2$3.class
Binary file not shown.
Binary file added bin/GUI2.class
Binary file not shown.
Binary file added bin/SGUI$1.class
Binary file not shown.
Binary file added bin/SGUI$2.class
Binary file not shown.
Binary file added bin/SGUI$3.class
Binary file not shown.
Binary file added bin/SGUI.class
Binary file not shown.
Binary file added bin/Sudoku$InvalidException.class
Binary file not shown.
Binary file added bin/Sudoku.class
Binary file not shown.
129 changes: 129 additions & 0 deletions src/GUI2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@


import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.border.TitledBorder;
import java.awt.GridLayout;

public class GUI2 {

public JFrame frmSudokuSolver;
public JLabel invalidExceptionLabel;
private JLabel lblNewLabel;
JTextField[][] table = new JTextField[9][9];

/**
* Launch the application.
*/

public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
GUI2 window = new GUI2();
window.frmSudokuSolver.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}


/**
* Create the application.
*/
public GUI2() {
initialize();
frmSudokuSolver.setVisible(true);
}


/**
* Initialize the contents of the frame.
*/
@SuppressWarnings("serial")
private void initialize() {
frmSudokuSolver = new JFrame();
frmSudokuSolver.setTitle("Sudoku Solver");
frmSudokuSolver.setResizable(false);
frmSudokuSolver.setBounds(100, 100, 450, 559);
frmSudokuSolver.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmSudokuSolver.getContentPane().setLayout(null);

JButton btnSolve = new JButton("Solve");
btnSolve.setFocusPainted(false);
btnSolve.setContentAreaFilled(false);
btnSolve.setFont(new Font("Cairo light", Font.PLAIN, 15));
btnSolve.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
invalidExceptionLabel.setText("");
Sudoku.solve();
}
});
btnSolve.setBounds(71, 486, 110, 23);
frmSudokuSolver.getContentPane().add(btnSolve);

JPanel boardPanel = new JPanel();
boardPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Board: ", TitledBorder.LEFT, TitledBorder. TOP,new Font("Cairo SemiBold", Font.PLAIN, 10), new Color(0, 0, 0)));
boardPanel.setBounds(71, 126, 308, 319);
frmSudokuSolver.getContentPane().add(boardPanel);
boardPanel.setLayout(new GridLayout(9, 9, 0, 0));

for (int i = 0; i < table.length; i++) {
for (int j = 0; j < table.length; j++) {
table[i][j] = new JTextField();
table[i][j].setHorizontalAlignment(JTextField.CENTER);
boardPanel.add(table[i][j]);
}
}

JButton btnReset = new JButton("Reset");
btnReset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
table[i][j].setText("");;
}
}
}
});
btnReset.setBounds(269, 486, 110, 23);
btnReset.setFocusPainted(false);
btnReset.setContentAreaFilled(false);
btnReset.setFont(new Font("Cairo light", Font.PLAIN, 15));
frmSudokuSolver.getContentPane().add(btnReset);

invalidExceptionLabel = new JLabel("");
invalidExceptionLabel.setFont(new Font("Tahoma", Font.BOLD, 11));
invalidExceptionLabel.setForeground(Color.RED);
invalidExceptionLabel.setBounds(40, 102, 370, 14);
invalidExceptionLabel.setHorizontalAlignment(JLabel.CENTER);
frmSudokuSolver.getContentPane().add(invalidExceptionLabel);

lblNewLabel = new JLabel("Sudoku Solver");
lblNewLabel.setFont(new Font("Cairo Light", Font.PLAIN, 23));
lblNewLabel.setHorizontalAlignment(JLabel.CENTER);
lblNewLabel.setBounds(92, 39, 266, 52);
frmSudokuSolver.getContentPane().add(lblNewLabel);
}

public void loadNums(int[][] arr_board) {
for (int i = 0; i < arr_board.length; i++) {
for (int j = 0; j < arr_board[i].length; j++) {
table[i][j].setText(""+arr_board[i][j]);
}
}
}

}
176 changes: 176 additions & 0 deletions src/SGUI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@


import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;

public class SGUI {

public JFrame frmSudokuSolver;
public JTable table;
public JLabel invalidExceptionLabel;
private JLabel lblNewLabel;

/**
* Launch the application.
*/
/*
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
SGUI window = new SGUI();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
*/

/**
* Create the application.
*/
public SGUI() {
initialize();
frmSudokuSolver.setVisible(true);
}


/**
* Initialize the contents of the frame.
*/
@SuppressWarnings("serial")
private void initialize() {
frmSudokuSolver = new JFrame();
frmSudokuSolver.setTitle("Sudoku Solver");
frmSudokuSolver.setResizable(false);
frmSudokuSolver.setBounds(100, 100, 450, 559);
frmSudokuSolver.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmSudokuSolver.getContentPane().setLayout(null);

JButton btnSolve = new JButton("Solve");
btnSolve.setFocusPainted(false);
btnSolve.setContentAreaFilled(false);
btnSolve.setFont(new Font("Cairo light", Font.PLAIN, 15));
btnSolve.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
invalidExceptionLabel.setText("");
Sudoku.solve();
}
});
btnSolve.setBounds(71, 486, 110, 23);
frmSudokuSolver.getContentPane().add(btnSolve);

JPanel boardPanel = new JPanel();
boardPanel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Board: ", TitledBorder.LEFT, TitledBorder. TOP,new Font("Cairo SemiBold", Font.PLAIN, 10), new Color(0, 0, 0)));
boardPanel.setBounds(71, 126, 308, 319);
frmSudokuSolver.getContentPane().add(boardPanel);
boardPanel.setLayout(null);

table = new JTable();
table.setBounds(6, 16, 296, 296);
boardPanel.add(table);
table.setFont(new Font("Tahoma", Font.PLAIN, 11));
table.setModel(new DefaultTableModel(
new Object[][] {
{null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null},
},
new String[] {
"0", "1", "2", "3", "4", "5", "6", "7", "8"
}
) {
Class[] columnTypes = new Class[] {
Integer.class, Integer.class, Integer.class, Integer.class, Integer.class, Integer.class, Integer.class, Integer.class, Integer.class
};
public Class getColumnClass(int columnIndex) {
return columnTypes[columnIndex];
}
});
table.getColumnModel().getColumn(0).setResizable(false);
table.getColumnModel().getColumn(0).setPreferredWidth(33);
table.getColumnModel().getColumn(0).setMinWidth(33);
table.getColumnModel().getColumn(0).setMaxWidth(33);
table.getColumnModel().getColumn(1).setResizable(false);
table.getColumnModel().getColumn(1).setPreferredWidth(33);
table.getColumnModel().getColumn(1).setMinWidth(33);
table.getColumnModel().getColumn(1).setMaxWidth(33);
table.getColumnModel().getColumn(2).setResizable(false);
table.getColumnModel().getColumn(2).setPreferredWidth(33);
table.getColumnModel().getColumn(2).setMinWidth(33);
table.getColumnModel().getColumn(2).setMaxWidth(33);
table.getColumnModel().getColumn(3).setResizable(false);
table.getColumnModel().getColumn(3).setPreferredWidth(33);
table.getColumnModel().getColumn(3).setMinWidth(33);
table.getColumnModel().getColumn(3).setMaxWidth(33);
table.getColumnModel().getColumn(4).setResizable(false);
table.getColumnModel().getColumn(4).setPreferredWidth(33);
table.getColumnModel().getColumn(4).setMinWidth(33);
table.getColumnModel().getColumn(4).setMaxWidth(33);
table.getColumnModel().getColumn(5).setResizable(false);
table.getColumnModel().getColumn(5).setPreferredWidth(33);
table.getColumnModel().getColumn(5).setMinWidth(33);
table.getColumnModel().getColumn(5).setMaxWidth(33);
table.getColumnModel().getColumn(6).setResizable(false);
table.getColumnModel().getColumn(6).setPreferredWidth(33);
table.getColumnModel().getColumn(6).setMinWidth(33);
table.getColumnModel().getColumn(6).setMaxWidth(33);
table.getColumnModel().getColumn(7).setResizable(false);
table.getColumnModel().getColumn(7).setPreferredWidth(33);
table.getColumnModel().getColumn(7).setMinWidth(33);
table.getColumnModel().getColumn(7).setMaxWidth(33);
table.getColumnModel().getColumn(8).setResizable(false);
table.getColumnModel().getColumn(8).setPreferredWidth(33);
table.getColumnModel().getColumn(8).setMinWidth(33);
table.getColumnModel().getColumn(8).setMaxWidth(33);
table.setRowHeight(33);

JButton btnReset = new JButton("Reset");
btnReset.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
for (int i = 0; i < 9; i++) {
for (int j = 0; j < 9; j++) {
table.setValueAt(null, i, j);
}
}
}
});
btnReset.setBounds(269, 486, 110, 23);
btnReset.setFocusPainted(false);
btnReset.setContentAreaFilled(false);
btnReset.setFont(new Font("Cairo light", Font.PLAIN, 15));
frmSudokuSolver.getContentPane().add(btnReset);

invalidExceptionLabel = new JLabel("");
invalidExceptionLabel.setFont(new Font("Tahoma", Font.BOLD, 11));
invalidExceptionLabel.setForeground(Color.RED);
invalidExceptionLabel.setBounds(40, 102, 370, 14);
invalidExceptionLabel.setHorizontalAlignment(JLabel.CENTER);
frmSudokuSolver.getContentPane().add(invalidExceptionLabel);

lblNewLabel = new JLabel("Sudoku Solver");
lblNewLabel.setFont(new Font("Cairo Light", Font.PLAIN, 23));
lblNewLabel.setHorizontalAlignment(JLabel.CENTER);
lblNewLabel.setBounds(92, 39, 266, 52);
frmSudokuSolver.getContentPane().add(lblNewLabel);
}
}
Loading

0 comments on commit 3dde5b8

Please sign in to comment.