basic GUI structure implemented, along with -c or --cli flags to run in a CLI rather than launch the GUI.

This commit is contained in:
Josh Ashton
2024-03-20 23:02:13 -06:00
parent 897af47658
commit 3cd71bf987
6 changed files with 60 additions and 2 deletions
+58
View File
@@ -0,0 +1,58 @@
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import java.awt.BorderLayout;
import java.awt.Dimension;
/**
* Runner class for the Sudoku App, managing the GUI and coordinating internal logic.
*/
public class App extends JFrame {
private Settings settings;
public App() {
super("Sudoku");
settings = new Settings();
initSetup();
}
/**
* Basic JFrame setup for the GUI.
*/
private void initSetup() {
// TODO: These are just some default values, these should use the values from Settings.
setDefaultCloseOperation(EXIT_ON_CLOSE);
setLayout(new BorderLayout());
setPreferredSize(new Dimension(750, 550));
setSize(getPreferredSize());
setResizable(false);
setLocationRelativeTo(null);
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) {
System.out.println("Error with cross platform look/feel in frameSetup().");
}
}
private JPanel createApp() {
// TODO: Create the root JPanel holding all other GUI components.
return null;
}
public static void cli() {
Nav nav = new Nav(new Settings());
SudokuChecker check = new SudokuChecker(nav.getLoadedGrid());
}
public static void main(String[] args) {
if(args.length == 0)
new App().setVisible(true);
else if(args[0].equals("-c") || args[0].equals("--cli"))
cli();
else
new App().setVisible(true);
}
}
+1 -1
View File
@@ -89,7 +89,7 @@ public class Nav extends JPanel {
* @param String
*/
private void openFile(String filename) {
File f = new File(/*"spring24/sudoku/" + */filename + ".sdku");
File f = new File("resources/" + filename + ".sdku");
if(f == null || !f.exists() || f.isDirectory() || !f.canRead()) {
System.out.println(
"The file " + filename +
+9
View File
@@ -0,0 +1,9 @@
53..7....
6..195...
.98....6.
8...6...3
4..8.3..1
7...2...6
.6....28.
...419..5
....8..79
+9
View File
@@ -0,0 +1,9 @@
.9...2.7.
.....3..6
..196..8.
4......1.
.....6...
.3.75...8
...2.....
.7.89...5
..3...7..
+9
View File
@@ -0,0 +1,9 @@
8.14.....
.4.83...6
6..5921.4
27.1.9538
...6..4.9
59.3...7.
.2.....65
36.95..1.
........3
+1 -1
View File
@@ -1,3 +1,3 @@
javac *.java
java Sudoku
java App -c
rm *.class