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 * @param String
*/ */
private void openFile(String filename) { 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()) { if(f == null || !f.exists() || f.isDirectory() || !f.canRead()) {
System.out.println( System.out.println(
"The file " + filename + "The file " + filename +
+1 -1
View File
@@ -1,3 +1,3 @@
javac *.java javac *.java
java Sudoku java App -c
rm *.class rm *.class