Add a context menu to edit boxes type

model:
* New methods to directly set boxes type instead of only toggling
  (setXBox methods)
* toggleBox now calls setXBox methods

ui:
* Add a context menu, enabled on right click, to directly choose the
  type of a box in the maze
* Defer the calculation of the box coordinates in the matrix to two new
  methods, getBoxRow and getBoxLine
This commit is contained in:
regar42 committed 2017-12-29 12:04:15 +01:00
1 parent 37def85f5b
commit 81df80e7ea
7 files changed
+196 -34

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
package ui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
public class SetDBoxMenuItem extends JMenuItem
implements ActionListener {
private final MazeApp mazeApp;
private final int boxLine;
private final int boxRow;
public SetDBoxMenuItem(MazeApp mazeApp, int boxLine, int boxRow) {
super("Set Departure Box");
this.mazeApp = mazeApp;
this.boxLine = boxLine;
this.boxRow = boxRow;
addActionListener(this);
}
public void actionPerformed(ActionEvent evt) {
mazeApp.getMazeAppModel().setDBox(boxLine, boxRow);
}
}