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:
@@ -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
@@ -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
@@ -1,3 +1,3 @@
|
|||||||
javac *.java
|
javac *.java
|
||||||
java Sudoku
|
java App -c
|
||||||
rm *.class
|
rm *.class
|
||||||
|
|||||||
Reference in New Issue
Block a user