Files
TpMazeJava/src/ui/SetEBoxMenuItem.java
T
regar42 81df80e7ea 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
2017-12-29 12:04:15 +01:00

27 lines
594 B
Java

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);
}
}