model: * Add an attribute to MazeAppModel to keep track of if the path is drawn or not. For future use to enable/disable the Clear button depending on if the path is drawn or not ui: * Add a "Clear shortest path" button to the Maze menu * Add a method to clear the path in MazeApp (just trigger a repainting of the MazeApp, which erase the path, since its not drawn by default) and update MazeAppModel accordingly
20 lines
432 B
Java
20 lines
432 B
Java
package ui;
|
|
|
|
import javax.swing.JMenu;
|
|
|
|
public class MazeMenu extends JMenu {
|
|
|
|
private final MazeApp mazeApp;
|
|
private final DrawShortestPathMenuItem drawMenuItem;
|
|
private final ClearShortestPathMenuItem clearMenuItem;
|
|
|
|
public MazeMenu(MazeApp mazeApp) {
|
|
|
|
super("Maze");
|
|
this.mazeApp = mazeApp;
|
|
|
|
add(drawMenuItem = new DrawShortestPathMenuItem(mazeApp));
|
|
add(clearMenuItem = new ClearShortestPathMenuItem(mazeApp));
|
|
}
|
|
}
|