Files
TpMazeJava/src/ui/ClearShortestPathMenuItem.java
T
regar42 7242872b83 Add a button to clear path
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
2017-12-24 21:27:20 +01:00

26 lines
496 B
Java

package ui;
import javax.swing.JMenuItem;
import model.MazeAppModel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ClearShortestPathMenuItem extends JMenuItem
implements ActionListener {
private final MazeApp mazeApp;
public ClearShortestPathMenuItem(MazeApp mazeApp) {
super("Clear shortest path");
this.mazeApp = mazeApp;
addActionListener(this);
}
public void actionPerformed(ActionEvent evt) {
mazeApp.clearShortestPath();
}
}