diff --git a/src/App.java b/src/App.java new file mode 100644 index 0000000..4e0a96d --- /dev/null +++ b/src/App.java @@ -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); + } +} diff --git a/src/Nav.java b/src/Nav.java index 118d031..dd6532e 100644 --- a/src/Nav.java +++ b/src/Nav.java @@ -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 + diff --git a/resources/input.sdku b/src/resources/input.sdku similarity index 100% rename from resources/input.sdku rename to src/resources/input.sdku diff --git a/resources/master-difficulty.sdku b/src/resources/master-difficulty.sdku similarity index 100% rename from resources/master-difficulty.sdku rename to src/resources/master-difficulty.sdku diff --git a/resources/test.sdku b/src/resources/test.sdku similarity index 100% rename from resources/test.sdku rename to src/resources/test.sdku diff --git a/src/run.ps1 b/src/run.ps1 index 9d21467..3dbdacf 100644 --- a/src/run.ps1 +++ b/src/run.ps1 @@ -1,3 +1,3 @@ javac *.java -java Sudoku +java App -c rm *.class