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:
1 parent
37def85f5b
commit
81df80e7ea
7 files changed
+196
-34
No files matched your search
@@ -0,0 +1,26 @@
|
||||
package ui;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
|
||||
public class SetEBoxMenuItem extends JMenuItem
|
||||
implements ActionListener {
|
||||
|
||||
private final MazeApp mazeApp;
|
||||
private final int boxLine;
|
||||
private final int boxRow;
|
||||
|
||||
public SetEBoxMenuItem(MazeApp mazeApp, int boxLine, int boxRow) {
|
||||
super("Set Empty Box");
|
||||
this.mazeApp = mazeApp;
|
||||
this.boxLine = boxLine;
|
||||
this.boxRow = boxRow;
|
||||
addActionListener(this);
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent evt) {
|
||||
mazeApp.getMazeAppModel().setEBox(boxLine, boxRow);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user