lisPlayerInfo = new List(5); lisPlayerInfo.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent e) { butRemoveBot.setEnabled(false); Client c = getPlayerListSelected(lisPlayerInfo); if (c == null) { lisPlayerInfo.select(-1); return; } if (c instanceof BotClient) { butRemoveBot.setEnabled(true); } choTeam.setSelectedIndex(c.getLocalPlayer().getTeam()); } });
lisPlayerInfo = new JList(new DefaultListModel()); lisPlayerInfo.addListSelectionListener(this);
    private void setupPlayerInfo() {        Player player = client.getLocalPlayer();        panPlayerInfo = new JPanel();        labPlayerInfo = new JLabel(Messages.getString("ChatLounge.labPlayerInfo")); //$NON-NLS-1$        lisPlayerInfo = new List(5);        lisPlayerInfo.addItemListener(new ItemListener() {            public void itemStateChanged(ItemEvent e) {                butRemoveBot.setEnabled(false);                Client c = getPlayerListSelected(lisPlayerInfo);                if (c == null) {                    lisPlayerInfo.select(-1);                    return;                }                if (c instanceof BotClient) {                    butRemoveBot.setEnabled(true);                }                choTeam.setSelectedIndex(c.getLocalPlayer().getTeam());            }        });        butAddBot = new JButton(Messages.getString("ChatLounge.butAddBot")); //$NON-NLS-1$        butAddBot.setActionCommand("add_bot"); //$NON-NLS-1$        butAddBot.addActionListener(this);        butRemoveBot = new JButton(Messages.getString("ChatLounge.butRemoveBot")); //$NON-NLS-1$        butRemoveBot.setEnabled(false);        butRemoveBot.setActionCommand("remove_bot"); //$NON-NLS-1$        butRemoveBot.addActionListener(this);        labTeam = new JLabel(Messages.getString("ChatLounge.labTeam"), JLabel.RIGHT); //$NON-NLS-1$        labCamo = new JLabel(Messages.getString("ChatLounge.labCamo"), JLabel.RIGHT); //$NON-NLS-1$        choTeam = new JComboBox();        choTeam.addItemListener(this);        setupTeams();        butCamo = new JButton();        butCamo.setText(Messages.getString("ChatLounge.noCamo")); //$NON-NLS-1$        butCamo.setPreferredSize(new Dimension(84, 72));        butCamo.setActionCommand("camo"); //$NON-NLS-1$        butCamo.addActionListener(this);        camoDialog.addItemListener(new CamoChoiceListener(camoDialog, butCamo, butOptions.getBackground(), player.getId(), client));        refreshCamos();        // If we have a camo pattern, use it.  Otherwise set a background.        Image[] images = (Image[]) camoDialog.getSelectedObjects();        if (null != images) {            butCamo.setIcon(new ImageIcon(images[0]));        } else {            butCamo.setBackground(PlayerColors.getColor(player.getColorIndex()));        }        // layout        GridBagLayout gridbag = new GridBagLayout();        GridBagConstraints c = new GridBagConstraints();        panPlayerInfo.setLayout(gridbag);        c.fill = GridBagConstraints.VERTICAL;        c.insets = new Insets(1, 1, 1, 1);        c.weightx = 1.0;        c.weighty = 0.0;        c.gridwidth = GridBagConstraints.REMAINDER;        gridbag.setConstraints(labPlayerInfo, c);        panPlayerInfo.add(labPlayerInfo);        c.fill = GridBagConstraints.BOTH;        c.weightx = 1.0;        c.weighty = 1.0;        gridbag.setConstraints(lisPlayerInfo, c);        panPlayerInfo.add(lisPlayerInfo);        c.gridwidth = 1;        c.weightx = 0.0;        c.weighty = 0.0;        gridbag.setConstraints(labTeam, c);        panPlayerInfo.add(labTeam);        c.gridwidth = GridBagConstraints.REMAINDER;        c.weightx = 1.0;        c.weighty = 0.0;        gridbag.setConstraints(choTeam, c);        panPlayerInfo.add(choTeam);        c.gridwidth = 1;        c.weightx = 0.0;        c.weighty = 0.0;        gridbag.setConstraints(labCamo, c);        panPlayerInfo.add(labCamo);        c.gridwidth = GridBagConstraints.REMAINDER;        c.weightx = 1.0;        c.weighty = 0.0;        gridbag.setConstraints(butCamo, c);        panPlayerInfo.add(butCamo);        c.gridwidth = 1;        c.weightx = 0.0;        c.weighty = 0.0;        gridbag.setConstraints(butAddBot, c);        panPlayerInfo.add(butAddBot);        c.gridwidth = GridBagConstraints.REMAINDER;        c.weightx = 1.0;        c.weighty = 0.0;        gridbag.setConstraints(butRemoveBot, c);        panPlayerInfo.add(butRemoveBot);        refreshPlayerInfo();    }