entity.setSpotlight(chSearchlight.getState());
    public void actionPerformed(java.awt.event.ActionEvent actionEvent) {        if (actionEvent.getSource() == butOffBoardDistance) {            int maxDistance = 19*17; // Long Tom            for (Enumeration i=entity.getWeapons(); i.hasMoreElements();) {                Mounted wep = (Mounted)i.nextElement();                EquipmentType e = wep.getType();                WeaponType w = (WeaponType)e;                if (w.hasFlag(WeaponType.F_ARTILLERY)) {                    int nDistance = (w.getLongRange()-1)*17;                    if (nDistance<maxDistance) {                        maxDistance = nDistance;                    }                }            }            Slider sl = new Slider (clientgui.frame, Messages.getString("CustomMechDialog.offboardDistanceTitle"), Messages.getString("CustomMechDialog.offboardDistanceQuestion"),                                    entity.getOffBoardDistance(), 17, maxDistance);            if (!sl.showDialog()) return;            distance = sl.getValue();            butOffBoardDistance.setLabel(Integer.toString(distance));            // butOffBoardDistance = new Button (Integer.toString(sl.getValue()));            // butOffBoardDistance.addActionListener(this);            return;        }        if (actionEvent.getSource() != butCancel) {            // get values            String name = fldName.getText();            int gunnery;            int piloting;            int offBoardDistance;            boolean autoEject = chAutoEject.getState();            try {                gunnery = Integer.parseInt(fldGunnery.getText());                piloting =  Integer.parseInt(fldPiloting.getText());            } catch (NumberFormatException e) {                new AlertDialog(clientgui.frame, Messages.getString("CustomMechDialog.NumberFormatError"), Messages.getString("CustomMechDialog.EnterValidSkills")).show(); //$NON-NLS-1$ //$NON-NLS-2$                return;            }                        // keep these reasonable, please            if (gunnery < 0 || gunnery > 7 || piloting < 0 || piloting > 7) {                new AlertDialog(clientgui.frame, Messages.getString("CustomMechDialog.NumberFormatError"), Messages.getString("CustomMechDialog.EnterSkillsBetween0_7")).show(); //$NON-NLS-1$ //$NON-NLS-2$                return;            }            if (chOffBoard.getState()){                try {                    offBoardDistance = distance;                } catch (NumberFormatException e) {                    new AlertDialog(clientgui.frame, Messages.getString("CustomMechDialog.NumberFormatError"), Messages.getString("CustomMechDialog.EnterValidSkills")).show(); //$NON-NLS-1$ //$NON-NLS-2$                    return;                }                if (offBoardDistance < 17) {                    new AlertDialog(clientgui.frame, Messages.getString("CustomMechDialog.NumberFormatError"), Messages.getString("CustomMechDialog.OffboardDistance")).show(); //$NON-NLS-1$ //$NON-NLS-2$                    return;                }                entity.setOffBoard( offBoardDistance,                                    choOffBoardDirection.getSelectedIndex() );            }            else {                entity.setOffBoard( 0, Entity.NONE );            }            // change entity            entity.setCrew(new Pilot(name, gunnery, piloting));            if (entity instanceof Mech) {                Mech mech = (Mech)entity;                mech.setAutoEject(!autoEject);            }            if(entity.hasC3() && choC3.getSelectedIndex() > -1) {                Entity chosen = client.getEntity                    ( entityCorrespondance[choC3.getSelectedIndex()] );                int entC3nodeCount =                     client.game.getC3SubNetworkMembers( entity ).size();                int choC3nodeCount =                     client.game.getC3NetworkMembers( chosen ).size();                if ( entC3nodeCount + choC3nodeCount <= Entity.MAX_C3_NODES ) {                    entity.setC3Master( chosen );                }                else {                    String message = Messages.getString("CustomMechDialog.NetworkTooBig.message", new Object[]{ //$NON-NLS-1$                            entity.getShortName(), chosen.getShortName(),                             new Integer(entC3nodeCount), new Integer(choC3nodeCount),                            new Integer(Entity.MAX_C3_NODES)});                    clientgui.doAlertDialog( Messages.getString("CustomMechDialog.NetworkTooBig.title"), //$NON-NLS-1$                                          message);                    refreshC3();                }            }            else if(entity.hasC3i() && choC3.getSelectedIndex() > -1) {                entity.setC3NetId(client.getEntity(entityCorrespondance[choC3.getSelectedIndex()]));            }            // Update the entity's targetting system type.            if (!(entity.hasTargComp()) && (clientgui.getClient().game.getOptions().booleanOption("allow_level_3_targsys"))) {                int targSysIndex = MiscType.T_TARGSYS_STANDARD;                if (choTargSys.getSelectedItem() != null)                    targSysIndex = MiscType.getTargetSysType(choTargSys.getSelectedItem());                if (targSysIndex >= 0)                    entity.setTargSysType(targSysIndex);                else {                    System.err.println("Illegal targetting system index: "+targSysIndex);                    entity.setTargSysType(MiscType.T_TARGSYS_STANDARD);                }            }            // If the player wants to swap unit numbers, update both            // entities and send an update packet for the other entity.            if ( !entityUnitNum.isEmpty() &&                 choUnitNum.getSelectedIndex() > 0 ) {                Entity other =  (Entity) this.entityUnitNum.elementAt                    ( choUnitNum.getSelectedIndex() );                char temp = this.entity.getUnitNumber();                this.entity.setUnitNumber( other.getUnitNumber() );                other.setUnitNumber( temp );                client.sendUpdateEntity( other );            }            // Set the entity's deployment round.            entity.setDeployRound(choDeployment.getSelectedIndex());            // update munitions selections            for (Enumeration e = m_vMunitions.elements(); e.hasMoreElements(); ) {                ((MunitionChoicePanel)e.nextElement()).applyChoice();            }            // update MG rapid fire settings            for (Enumeration e = m_vMGs.elements(); e.hasMoreElements(); ) {                ((RapidfireMGPanel)e.nextElement()).applyChoice();            }                        setOptions();                        okay = true;        }        this.setVisible(false);        Entity nextOne = null;        if (actionEvent.getSource() == butPrev) {            nextOne = getNextEntity(false);        } else if (actionEvent.getSource() == butNext) {            nextOne = getNextEntity(true);        }        if (nextOne!=null) {            clientgui.chatlounge.refreshEntities();            clientgui.chatlounge.customizeMech(nextOne);        }    }