Add UI to the project #29
No files matched your search
+1
-1
@@ -20,7 +20,7 @@ public class MainTest {
|
||||
|
||||
mazeTest.saveToTextFile("data/labyOutput.txt");
|
||||
|
||||
new MazeApp(mazeTest);
|
||||
new MazeApp();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
package model;
|
||||
|
||||
import maze.Maze;
|
||||
|
||||
public class MazeAppModel {
|
||||
|
||||
private Maze maze = new Maze("data/labyrinthe.txt");
|
||||
|
||||
public void setMaze(Maze maze) {
|
||||
this.maze = maze;
|
||||
}
|
||||
|
||||
public Maze getMaze() {
|
||||
return maze;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,6 @@ public abstract class DrawingBox extends JPanel {
|
||||
this.color = color;
|
||||
|
||||
setBackground(color);
|
||||
setPreferredSize(new Dimension(20,20));
|
||||
setPreferredSize(new Dimension(40,40));
|
||||
}
|
||||
}
|
||||
@@ -13,10 +13,10 @@ public class DrawingPanelGrid extends JPanel {
|
||||
private int dimensionX;
|
||||
private int dimensionY;
|
||||
|
||||
public DrawingPanelGrid(MazeApp mazeApp, Maze maze) {
|
||||
public DrawingPanelGrid(MazeApp mazeApp) {
|
||||
|
||||
this.mazeApp = mazeApp;
|
||||
this.maze = maze;
|
||||
this.maze = mazeApp.getMazeAppModel().getMaze();
|
||||
this.dimensionX = maze.getDimensionX();
|
||||
this.dimensionY = maze.getDimensionY();
|
||||
|
||||
|
||||
+7
-4
@@ -2,25 +2,28 @@ package ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import maze.Maze;
|
||||
import model.MazeAppModel;
|
||||
|
||||
public class MazeApp extends JFrame {
|
||||
|
||||
private final MazeMenuBar mazeMenuBar;
|
||||
private final WindowPanel windowPanel;
|
||||
private Maze maze;
|
||||
private MazeAppModel mazeAppModel = new MazeAppModel();
|
||||
|
||||
public MazeApp(Maze maze) {
|
||||
public MazeApp() {
|
||||
|
||||
super("Maze Solving Application");
|
||||
|
||||
setJMenuBar(mazeMenuBar = new MazeMenuBar(this));
|
||||
setContentPane(windowPanel = new WindowPanel(this, maze)) ;
|
||||
setContentPane(windowPanel = new WindowPanel(this)) ;
|
||||
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
pack();
|
||||
setVisible(true);
|
||||
|
||||
}
|
||||
|
||||
public MazeAppModel getMazeAppModel() {
|
||||
return mazeAppModel;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,6 @@ public class QuitMenuItem extends JMenuItem {
|
||||
|
||||
super("Quit");
|
||||
this.mazeApp = mazeApp;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,13 +7,12 @@ import java.awt.*;
|
||||
public class WindowPanel extends JPanel
|
||||
{
|
||||
private final DrawingPanelGrid drawingPanelGrid;
|
||||
private Maze maze;
|
||||
|
||||
public WindowPanel(MazeApp mazeApp, Maze maze)
|
||||
{
|
||||
public WindowPanel(MazeApp mazeApp) {
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
add(drawingPanelGrid = new DrawingPanelGrid(mazeApp, maze), BorderLayout.CENTER);
|
||||
add(drawingPanelGrid = new DrawingPanelGrid(mazeApp), BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user