Files
TpMazeJava/src/ui/AddRowMenuItem.java
T
regar42 e76db727c7 Fix regression on getDimensionX and add finals
* Make all appropriate methods final
* Add new messages to MazeAppModelMessage and handle them to act more
  accurately on observers updates
* Make all buttons from 'File' menu subclasses of FileMenu in order to
  have a cleaner ui folder
* Remove legacy code (for example, the former code used to animate the
  path drawing)
* Improve delegation
2018-01-14 14:00:07 +01:00

40 lines
719 B
Java

package ui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
public final class AddRowMenuItem extends JMenuItem
implements ActionListener {
private final MazeApp mazeApp;
private final int rowNum;
public AddRowMenuItem(MazeApp mazeApp) {
super("Add row");
this.mazeApp = mazeApp;
rowNum = -1;
addActionListener(this);
}
public AddRowMenuItem(MazeApp mazeApp, int rowNum) {
super("Add row");
this.mazeApp = mazeApp;
this.rowNum = rowNum;
addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
if (rowNum == -1) {
mazeApp.addEmptyColumn();
}
else {
mazeApp.addEmptyColumn(rowNum);
}
}
}