* Remove legacy test code in MainTest maze: * Add methods to add/del lines and columns * Add various calls to matrixDeepCopy, allowing to overwrite only a part of a matrix model: * Better delegation to Maze : let Maze handle column/line adds/deletions ui: * Add buttons to context menu to add/remove lines and columns * Add buttons to Maze Menu to delete lines and columns * Fix the spinners, it used to call a new instance of itself, which made impossible to simple get the values from the spinners
39 lines
716 B
Java
39 lines
716 B
Java
package ui;
|
|
|
|
import java.awt.event.ActionEvent;
|
|
import java.awt.event.ActionListener;
|
|
|
|
import javax.swing.JMenuItem;
|
|
|
|
public class DelLineMenuItem extends JMenuItem
|
|
implements ActionListener {
|
|
|
|
private final MazeApp mazeApp;
|
|
private final int lineNum;
|
|
|
|
public DelLineMenuItem(MazeApp mazeApp) {
|
|
|
|
super("Delete line");
|
|
this.mazeApp = mazeApp;
|
|
lineNum = -1;
|
|
addActionListener(this);
|
|
}
|
|
|
|
public DelLineMenuItem(MazeApp mazeApp, int lineNum) {
|
|
super("Delete line");
|
|
this.mazeApp = mazeApp;
|
|
this.lineNum = lineNum;
|
|
addActionListener(this);
|
|
}
|
|
|
|
@Override
|
|
public void actionPerformed(ActionEvent e) {
|
|
if (lineNum == -1) {
|
|
mazeApp.delLine();
|
|
}
|
|
else {
|
|
mazeApp.delLine(lineNum);
|
|
}
|
|
}
|
|
}
|