public void actionPerformed(ActionEvent event) { if (scene.canRemove()) // If shapes can be removed { scene.removeSelected(); // if no more objects can be removed, disable this action if (!scene.canRemove()) { setEnabled(false); } // check if the opposites can be enabled. checkOpposite(); } else { // disable this action, check if opposites can be enabled setEnabled(false); checkOpposite(); } }
/** Checks if the opposite actions should be enabled/disabled */ public void checkOpposite() { for (int i = 0; i < opposite.size(); i++) { if (scene.canAdd(opposite.get(i).getName())) opposite.get(i).setEnabled(true); else opposite.get(i).setEnabled(false); } }