ui: * Add methods to draw the shortest path from MazeApp, WindowPanel and MazeDrawing * Add a Maze menu with a button to draw the shortest path from departure to arrival
26 lines
492 B
Java
26 lines
492 B
Java
package ui;
|
|
|
|
import javax.swing.JMenuItem;
|
|
|
|
import model.MazeAppModel;
|
|
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionListener;
|
|
|
|
public class DrawShortestPathMenuItem extends JMenuItem
|
|
implements ActionListener {
|
|
|
|
private final MazeApp mazeApp;
|
|
|
|
public DrawShortestPathMenuItem(MazeApp mazeApp) {
|
|
|
|
super("Draw shortest path");
|
|
this.mazeApp = mazeApp;
|
|
addActionListener(this);
|
|
}
|
|
|
|
public void actionPerformed(ActionEvent evt) {
|
|
mazeApp.drawShortestPath();
|
|
}
|
|
}
|