public void actionPerformed(ActionEvent e) {
ObjectsButton button = (ObjectsButton) e.getSource();
Vector<MapObject> mapObjects = button.getMapObjects();
Vector<JCheckBox> checkBoxes = button.getCheckBoxes();
Field field = button.getField();
QuadMap map = button.getMap();
Vector<MapObject> delObjects = new Vector();
for (int i = 0; i<mapObjects.size(); i++) {
if (checkBoxes.get(i).isSelected()) {
delObjects.add(mapObjects.get(i));
}
}
if (!delObjects.isEmpty()) {
removeObjects(delObjects, map, field.getPosition());
}
setVisible(false);
}
});
ObjectsButton removeAllButton = new ObjectsButton(
this.mapObjects, this.checkBoxes, "Remove all",
field, this.map);
removeAllButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ObjectsButton button = (ObjectsButton) e.getSource();
Vector<MapObject> mapObjects = button.getMapObjects();
Field field = button.getField();
QuadMap map = button.getMap();
removeObjects(mapObjects, map, field.getPosition());
setVisible(false);
}
});