torsoEquipment = new Vector();
torsoEquipment = new Vector<BattleArmorEquipment>();
    public void actionPerformed(ActionEvent ae) {        if (ae.getSource() == m_buttonReset) {            resetState();            return;        } else if (ae.getSource() == m_buttonAddTorso) {            BattleArmorEquipment tmpBAE = (BattleArmorEquipment)(equipmentTypes.get(equipmentNames.indexOf(m_chTorsoEquipment.getSelectedItem())));            if (torsoEquipment == null)                torsoEquipment = new Vector();            torsoEquipment.add(tmpBAE);            stateConflictFlags |= tmpBAE.conflictFlag;            // Make sure the BA preview is now correct...            previewBA();            // Make sure we update the equpment choices, since they may have now changed...            updateEquipmentChoices();            // Nothing else in actionPerformed will matter, so lets move on!            return;        } else if (ae.getSource() == m_buttonAddRightArm) {            BattleArmorEquipment tmpBAE = (BattleArmorEquipment)(equipmentTypes.get(equipmentNames.indexOf(m_chRightArmEquipment.getSelectedItem())));            if (rightArmEquipment == null)                rightArmEquipment = new Vector();            rightArmEquipment.add(tmpBAE);            stateConflictFlags |= tmpBAE.conflictFlag;            // Make sure the BA preview is now correct...            previewBA();            // Make sure we update the equpment choices, since they may have now changed...            updateEquipmentChoices();            // Nothing else in actionPerformed will matter, so lets move on!            return;        } else if (ae.getSource() == m_buttonAddLeftArm) {            BattleArmorEquipment tmpBAE = (BattleArmorEquipment)(equipmentTypes.get(equipmentNames.indexOf(m_chLeftArmEquipment.getSelectedItem())));            if (leftArmEquipment == null)                leftArmEquipment = new Vector();            leftArmEquipment.add(tmpBAE);            stateConflictFlags |= tmpBAE.conflictFlag;            // Make sure the BA preview is now correct...            previewBA();            // Make sure we update the equpment choices, since they may have now changed...            updateEquipmentChoices();            // Nothing else in actionPerformed will matter, so lets move on!            return;        } else if (ae.getSource() == m_buttonRemoveTorso) {            if (torsoEquipment != null) {                String removeItem = m_chTorsoCurrentEquipment.getSelectedItem();                Enumeration tmpE = torsoEquipment.elements();                while (tmpE.hasMoreElements()) {                    BattleArmorEquipment tmpBAE = (BattleArmorEquipment)(tmpE.nextElement());                    if (tmpBAE.name.equals(removeItem)) {                        torsoEquipment.remove(tmpBAE);                        break;                    }                }                if (torsoEquipment.size() <= 0)                    torsoEquipment = null;                    // Make sure the BA preview is now correct...                previewBA();                    // Make sure we update the equpment choices, since they may have now changed...                updateEquipmentChoices();            }            // Nothing else in actionPerformed will matter, so lets move on!            return;        } else if (ae.getSource() == m_buttonRemoveRightArm) {            if (rightArmEquipment != null) {                String removeItem = m_chRightArmCurrentEquipment.getSelectedItem();                Enumeration tmpE = rightArmEquipment.elements();                while (tmpE.hasMoreElements()) {                    BattleArmorEquipment tmpBAE = (BattleArmorEquipment)(tmpE.nextElement());                    if (tmpBAE.name.equals(removeItem)) {                        rightArmEquipment.remove(tmpBAE);                        break;                    }                }                if (rightArmEquipment.size() <= 0)                    rightArmEquipment = null;                    // Make sure the BA preview is now correct...                previewBA();                    // Make sure we update the equpment choices, since they may have now changed...                updateEquipmentChoices();            }            // Nothing else in actionPerformed will matter, so lets move on!            return;        } else if (ae.getSource() == m_buttonRemoveLeftArm) {            if (leftArmEquipment != null) {                String removeItem = m_chLeftArmCurrentEquipment.getSelectedItem();                Enumeration tmpE = leftArmEquipment.elements();                while (tmpE.hasMoreElements()) {                    BattleArmorEquipment tmpBAE = (BattleArmorEquipment)(tmpE.nextElement());                    if (tmpBAE.name.equals(removeItem)) {                        leftArmEquipment.remove(tmpBAE);                        break;                    }                }                if (leftArmEquipment.size() <= 0)                    leftArmEquipment = null;                    // Make sure the BA preview is now correct...                previewBA();                    // Make sure we update the equpment choices, since they may have now changed...                updateEquipmentChoices();            }            // Nothing else in actionPerformed will matter, so lets move on!            return;        } else if ((ae.getSource() == m_bPick) || (ae.getSource() == m_bPickClose)) {            // Here, we need to add the current BA as a new entity, if it can legally do so...            if (!isValid()) {                new megamek.client.ui.AWT.AlertDialog(m_clientgui.frame, "Can't do that!", "You can't add an invalid unit.").setVisible(true);                return;            }            try {                BattleArmor e = getEntity();                Client c = null;                if (m_chPlayer.getSelectedIndex() > 0) {                    String name = m_chPlayer.getSelectedItem();                    c = (Client)m_clientgui.getBots().get(name);                }                if (c == null) {                    c = m_client;                }                e.setOwner(c.getLocalPlayer());                c.sendAddEntity(e);            } catch (Exception ex) {                System.err.println("Error while loading custom BattleArmor!");                ex.printStackTrace();                return;            }        } else if(ae.getSource() == m_bSave ) {            FileDialog fd = new FileDialog(m_clientgui.frame, Messages.getString("CustomBattleArmorDialog.FileSaveDialog"), FileDialog.SAVE); //$NON-NLS-1$            fd.setDirectory("data/mechfiles/");            fd.setFile(m_tfBAName.getText()+".blk");            fd.setFilenameFilter(new FilenameFilter() { public boolean accept(File f, String s) {return s.endsWith(".blk"); } });            fd.setModal(true);            fd.setVisible(true);            String filename = fd.getDirectory() + File.separator + fd.getFile();            if(filename.indexOf('.') == -1)                filename = filename + ".blk";            File f = new File(filename);            try {                BattleArmor ba = getEntity();                FileWriter wr = new FileWriter(f);                wr.write(ba.getBLK());                wr.close();            } catch (Exception ex) {                ex.printStackTrace();            }        }        // Specifically NOT an else/if, because this can happen at the same time as one option above.        if ((ae.getSource() == m_bCancel) || (ae.getSource() == m_bPickClose)) {            this.setVisible(false);        }    }