for (Enumeration i = entity.getWeapons(); i.hasMoreElements();) { Mounted mounted = (Mounted)i.nextElement();
for (Mounted mounted : entity.getWeaponList()) {
    public CustomMechDialog(ClientGUI clientgui, Client client, Entity entity, boolean editable) {        super(clientgui.frame, Messages.getString("CustomMechDialog.title"), true); //$NON-NLS-1$                Panel tempPanel = new Panel();        this.entity = entity;        this.clientgui = clientgui;        this.client = client;        this.options = entity.getCrew().getOptions();        this.editable = editable;                texDesc.setEditable(false);                // layout        GridBagLayout gridbag = new GridBagLayout();        GridBagConstraints c = new GridBagConstraints();        tempPanel.setLayout(gridbag);                    c.fill = GridBagConstraints.VERTICAL;        c.insets = new Insets(5, 5, 5, 5);                    c.weightx = 1.0;    c.weighty = 1.0;        c.gridwidth = 1;        c.anchor = GridBagConstraints.EAST;        gridbag.setConstraints(labName, c);        tempPanel.add(labName);                c.gridwidth = GridBagConstraints.REMAINDER;        c.anchor = GridBagConstraints.WEST;        gridbag.setConstraints(fldName, c);        tempPanel.add(fldName);                c.gridwidth = 1;        c.anchor = GridBagConstraints.EAST;        gridbag.setConstraints(labGunnery, c);        tempPanel.add(labGunnery);                c.gridwidth = GridBagConstraints.REMAINDER;        c.anchor = GridBagConstraints.WEST;        gridbag.setConstraints(fldGunnery, c);        tempPanel.add(fldGunnery);                c.gridwidth = 1;        c.anchor = GridBagConstraints.EAST;        gridbag.setConstraints(labPiloting, c);        tempPanel.add(labPiloting);                c.gridwidth = GridBagConstraints.REMAINDER;        c.anchor = GridBagConstraints.WEST;        gridbag.setConstraints(fldPiloting, c);        tempPanel.add(fldPiloting);                // Auto-eject checkbox.        if (entity instanceof Mech) {            Mech mech = (Mech)entity;            // Torso-mounted cockpits can't eject, so lets not bother showing this.            if (mech.getCockpitType() != Mech.COCKPIT_TORSO_MOUNTED) {                c.gridwidth = 1;                c.anchor = GridBagConstraints.EAST;                gridbag.setConstraints(labAutoEject, c);                tempPanel.add(labAutoEject);                            c.gridwidth = GridBagConstraints.REMAINDER;                c.anchor = GridBagConstraints.WEST;                gridbag.setConstraints(chAutoEject, c);                tempPanel.add(chAutoEject);                chAutoEject.setState(!mech.isAutoEject());            }        }                c.gridwidth = 1;        c.anchor = GridBagConstraints.EAST;        gridbag.setConstraints(labDeployment, c);        tempPanel.add(labDeployment);              c.gridwidth = GridBagConstraints.REMAINDER;        c.anchor = GridBagConstraints.WEST;        gridbag.setConstraints(choDeployment, c);        tempPanel.add(choDeployment);        refreshDeployment();        if ( clientgui.getClient().game.getOptions().booleanOption("pilot_advantages") ) { //$NON-NLS-1$            scrOptions.add(panOptions);            c.weightx = 1.0;    c.weighty = 1.0;            c.fill = GridBagConstraints.BOTH;            c.gridwidth = GridBagConstraints.REMAINDER;            gridbag.setConstraints(scrOptions, c);            tempPanel.add(scrOptions);            c.weightx = 1.0;    c.weighty = 0.0;            gridbag.setConstraints(texDesc, c);            tempPanel.add(texDesc);        }        if (entity.hasC3() || entity.hasC3i()) {                    c.gridwidth = 1;            c.anchor = GridBagConstraints.EAST;            gridbag.setConstraints(labC3, c);            tempPanel.add(labC3);            c.gridwidth = GridBagConstraints.REMAINDER;            c.anchor = GridBagConstraints.WEST;            gridbag.setConstraints(choC3, c);            tempPanel.add(choC3);            refreshC3();        }        boolean eligibleForOffBoard = false;        for (Enumeration i = entity.getWeapons(); i.hasMoreElements();) {            Mounted mounted = (Mounted)i.nextElement();            WeaponType wtype = (WeaponType)mounted.getType();            if (wtype.hasFlag(WeaponType.F_ARTILLERY)) {                eligibleForOffBoard = true;            }        }        if (eligibleForOffBoard) {            c.gridwidth = 1;            c.anchor = GridBagConstraints.EAST;            gridbag.setConstraints(labOffBoard, c);            tempPanel.add(labOffBoard);                      c.gridwidth = GridBagConstraints.REMAINDER;            c.anchor = GridBagConstraints.WEST;            gridbag.setConstraints(chOffBoard, c);            tempPanel.add(chOffBoard);            chOffBoard.setState(entity.isOffBoard());                        c.gridwidth = 1;            c.anchor = GridBagConstraints.EAST;            gridbag.setConstraints(labOffBoardDirection, c);            tempPanel.add(labOffBoardDirection);                        c.gridwidth = GridBagConstraints.REMAINDER;            c.anchor = GridBagConstraints.WEST;            gridbag.setConstraints(choOffBoardDirection, c);            choOffBoardDirection.add(Messages.getString("CustomMechDialog.North")); //$NON-NLS-1$            choOffBoardDirection.add(Messages.getString("CustomMechDialog.South")); //$NON-NLS-1$            choOffBoardDirection.add(Messages.getString("CustomMechDialog.East")); //$NON-NLS-1$            choOffBoardDirection.add(Messages.getString("CustomMechDialog.West")); //$NON-NLS-1$            direction = entity.getOffBoardDirection();            if ( IOffBoardDirections.NONE == direction ) {                direction = IOffBoardDirections.NORTH;            }            choOffBoardDirection.select( direction );            tempPanel.add(choOffBoardDirection);                        c.gridwidth = 1;            c.anchor = GridBagConstraints.EAST;            gridbag.setConstraints(labOffBoardDistance, c);            tempPanel.add(labOffBoardDistance);                        c.gridwidth = GridBagConstraints.REMAINDER;            c.anchor = GridBagConstraints.WEST;                        butOffBoardDistance.addActionListener(this);            gridbag.setConstraints(butOffBoardDistance, c);            butOffBoardDistance.setLabel(Integer.toString(distance));            tempPanel.add(butOffBoardDistance);        }        if (!(entity.hasTargComp()) && (clientgui.getClient().game.getOptions().booleanOption("allow_level_3_targsys")) && (entity instanceof Mech)) {            c.gridwidth = 1;            c.anchor = GridBagConstraints.EAST;            gridbag.setConstraints(labTargSys, c);            tempPanel.add(labTargSys);            c.gridwidth = GridBagConstraints.REMAINDER;            c.anchor = GridBagConstraints.WEST;            choTargSys.add(MiscType.getTargetSysName(MiscType.T_TARGSYS_STANDARD));            choTargSys.add(MiscType.getTargetSysName(MiscType.T_TARGSYS_LONGRANGE));            choTargSys.add(MiscType.getTargetSysName(MiscType.T_TARGSYS_SHORTRANGE));            choTargSys.add(MiscType.getTargetSysName(MiscType.T_TARGSYS_ANTI_AIR));//            choTargSys.add(MiscType.getTargetSysName(MiscType.T_TARGSYS_MULTI_TRAC));            gridbag.setConstraints(choTargSys, c);            tempPanel.add(choTargSys);            choTargSys.select(MiscType.getTargetSysName(entity.getTargSysType()));        }        if ( entity instanceof Protomech ) {            // All Protomechs have a callsign.            StringBuffer callsign = new StringBuffer(Messages.getString("CustomMechDialog.Callsign")); //$NON-NLS-1$            callsign.append(": ");  //$NON-NLS-1$            callsign.append( (char) (this.entity.getUnitNumber() +                    PreferenceManager.getClientPreferences().getUnitStartChar()) )                .append( '-' )                .append( this.entity.getId() );            labCallsign.setText( callsign.toString() );            c.gridwidth = GridBagConstraints.REMAINDER;            c.anchor = GridBagConstraints.CENTER;            gridbag.setConstraints(labCallsign, c);            tempPanel.add(labCallsign);            // Get the Protomechs of this entity's player            // that *aren't* in the entity's unit.            Enumeration otherUnitEntities = client.game.getSelectedEntities                ( new EntitySelector() {                        private final int ownerId =                            CustomMechDialog.this.entity.getOwnerId();                        private final char unitNumber =                            CustomMechDialog.this.entity.getUnitNumber();                        public boolean accept( Entity entity ) {                            if ( entity instanceof Protomech &&                                 ownerId == entity.getOwnerId() &&                                 unitNumber != entity.getUnitNumber() )                                return true;                            return false;                        }                    } );            // If we got any other entites, show the unit number controls.            if ( otherUnitEntities.hasMoreElements() ) {                c.gridwidth = 1;                c.anchor = GridBagConstraints.EAST;                gridbag.setConstraints(labUnitNum, c);                tempPanel.add(labUnitNum);                c.gridwidth = GridBagConstraints.REMAINDER;                c.anchor = GridBagConstraints.WEST;                gridbag.setConstraints(choUnitNum, c);                tempPanel.add(choUnitNum);                refreshUnitNum(otherUnitEntities);            }        }        // Can't set up munitions on infantry.        if ( !(entity instanceof Infantry) ) {            setupMunitions();            c.anchor = GridBagConstraints.CENTER;            gridbag.setConstraints(panMunitions, c);            tempPanel.add(panMunitions);        }                // Set up rapidfire mg        if (clientgui.getClient().game.getOptions().booleanOption("maxtech_burst")) { //$NON-NLS-1$            c.gridwidth = 1;            setupRapidfireMGs();            c.anchor = GridBagConstraints.CENTER;            gridbag.setConstraints(panRapidfireMGs, c);            tempPanel.add(panRapidfireMGs);        }                // Set up searchlight        if (clientgui.getClient().game.getOptions().booleanOption("night_battle")) { //$NON-NLS-1$            c.gridwidth = 1;            c.anchor = GridBagConstraints.EAST;            gridbag.setConstraints(labSearchlight, c);            tempPanel.add(labSearchlight);                        c.gridwidth = GridBagConstraints.REMAINDER;            c.anchor = GridBagConstraints.WEST;            gridbag.setConstraints(chSearchlight, c);            tempPanel.add(chSearchlight);            chSearchlight.setState(entity.hasSpotlight());                }        // Set up mines        setupMines();        c.anchor = GridBagConstraints.CENTER;        gridbag.setConstraints(panMines, c);        tempPanel.add(panMines);                setupButtons();                c.gridwidth = GridBagConstraints.REMAINDER;        c.anchor = GridBagConstraints.CENTER;        gridbag.setConstraints(panButtons, c);        tempPanel.add(panButtons);                fldName.setText(entity.getCrew().getName());        fldName.addActionListener(this);        fldGunnery.setText(new Integer(entity.getCrew().getGunnery()).toString());        fldGunnery.addActionListener(this);        fldPiloting.setText(new Integer(entity.getCrew().getPiloting()).toString());        fldPiloting.addActionListener(this);                if (!editable) {            fldName.setEnabled(false);            fldGunnery.setEnabled(false);            fldPiloting.setEnabled(false);            choC3.setEnabled(false);            choDeployment.setEnabled(false);            chAutoEject.setEnabled(false);            chSearchlight.setEnabled(false);            choTargSys.setEnabled(false);            disableMunitionEditing();            disableMGSetting();            disableMineSetting();            chOffBoard.setEnabled(false);            choOffBoardDirection.setEnabled(false);            fldOffBoardDistance.setEnabled(false);        }        scrAll.add(tempPanel);        // add the scrollable panel        this.add(scrAll);        addWindowListener(new WindowAdapter() {            public void windowClosing(WindowEvent e) { setVisible(false); }        });        pack();        //Why do we have to add all this stuff together to get the        // right size?  I hate GUI programming...especially AWT.        int w = tempPanel.getPreferredSize().width +            scrAll.getInsets().right;        int h = tempPanel.getPreferredSize().height +            panButtons.getPreferredSize().height +            scrAll.getInsets().bottom;        setLocationAndSize(w,h);    }