CamoChoiceDialog.this.itemStateChanged (new ItemEvent(items, event.getID(), items.getSelectedItem(), ItemEvent.SELECTED));
updateButton();
    public CamoChoiceDialog(JFrame parent) {        // Initialize our superclass and record our parent frame.        super(parent, Messages.getString("CamoChoiceDialog.select_camo_pattern"), true); //$NON-NLS-1$        frame = parent;        // Declare local variables.        Enumeration names;        String name;        // Parse the camo directory.        try {            camos = new DirectoryItems(new File("data/images/camo"), "", //$NON-NLS-1$ //$NON-NLS-2$                    ImageFileFactory.getInstance());        } catch (Exception e) {            camos = null;        }        // Close the window, when the WM says to.        addWindowListener(new WindowAdapter() {            public void windowClosing(WindowEvent e) {                close();            }        });                // Use a border layout.        getContentPane().setLayout(new BorderLayout());        // Create a pulldown menu for the categories.        JPanel panel = new JPanel();        getContentPane().add(panel, BorderLayout.NORTH);        panel.setLayout(new GridBagLayout());        GridBagConstraints layout = new GridBagConstraints();        layout.anchor = GridBagConstraints.CENTER;        categories = new JComboBox();        panel.add(categories, layout);        // Fill the pulldown.  Include the "no camo" category.        // Make sure the "no camo" and "root camo" are at top.        // Only add the "root camo" category if it contains items.        categories.addItem(Player.NO_CAMO);        if (camos != null) {            if (camos.getItemNames("").hasMoreElements()) { //$NON-NLS-1$                categories.addItem(Player.ROOT_CAMO);            }            names = camos.getCategoryNames();            while (names.hasMoreElements()) {                name = (String) names.nextElement();                if (!"".equals(name)) { //$NON-NLS-1$                    categories.addItem(name);                }            }        }        // Refill the item list when a new category is selected.        // Make sure that the "select new camo" button is updated.        categories.addItemListener(new ItemListener() {            public void itemStateChanged(ItemEvent event) {                fillList((String) event.getItem());                CamoChoiceDialog.this.itemStateChanged                        (new ItemEvent(items, event.getID(),                                items.getSelectedItem(),                                ItemEvent.SELECTED));            }        });        // Create a list to hold the items in the category.        items = new List(15);        getContentPane().add(items, BorderLayout.CENTER);        // Update the "select new camo" when an item is selected.        items.addItemListener(this);        // Create a panel to hold our buttons.        // Use a grid bag layout.        panel = new JPanel();        panel.setLayout(new GridBagLayout());        getContentPane().add(panel, BorderLayout.EAST);        layout = new GridBagConstraints();        layout.anchor = GridBagConstraints.EAST;        layout.gridx = 0;        layout.gridy = 0;        layout.gridwidth = 1;        layout.gridheight = 1;        layout.fill = GridBagConstraints.NONE;        layout.ipadx = 4;        layout.ipady = 4;        layout.weightx = 0.0;        layout.weighty = 0.0;        // Add a "spacer" label to push everything else to the bottom.        layout.weighty = 1.0;        panel.add(new JLabel(), layout);        layout.weighty = 0.0;        layout.gridy++;        // Add a label for the "keep old camo" button.        panel.add(new JLabel(Messages.getString("CamoChoiceDialog.keep_old_camo")), layout); //$NON-NLS-1$        layout.gridy++;        // Create the "keep old camo" button.        keep = new JButton();        keep.setText(Messages.getString("CamoChoiceDialog.no_camo")); //$NON-NLS-1$        keep.setPreferredSize(new Dimension(84, 72));        keep.addActionListener(new ActionListener() {            // Pressing this button closes without saving.            public void actionPerformed(ActionEvent event) {                close();            }        });        keep.addKeyListener(new KeyAdapter() {            public void keyPressed(KeyEvent event) {                // Pressing enter on this button closes without saving.                if (event.getKeyCode() == KeyEvent.VK_ENTER) {                    close();                }            }        });        panel.add(keep, layout);        layout.gridy++;        // Add a label for the "select new camo" button.        panel.add(new JLabel(Messages.getString("CamoChoiceDialog.select_new_camo")), layout); //$NON-NLS-1$        layout.gridy++;        // Create the "select new camo" button.        select = new JButton();        select.setText(Messages.getString("CamoChoiceDialog.no_camo")); //$NON-NLS-1$        select.setPreferredSize(new Dimension(84, 72));        select.addActionListener(this);        panel.add(select, layout);        // Fire the "select new camo" action when the enter key is pressed        // on either the list or the "select new camo" button.        KeyAdapter enterAdapter = new KeyAdapter() {            public void keyPressed(KeyEvent event) {                if (event.getKeyCode() == KeyEvent.VK_ENTER) {                    actionPerformed                            (new ActionEvent(select, event.getID(),                                    select.getActionCommand()));                }            }        };        items.addKeyListener(enterAdapter);        select.addKeyListener(enterAdapter);        // Set the "previously selected" values to the defaults.        setPrevSelection(Player.NO_CAMO, Player.colorNames[0]);        // Fill the item list with the colors.        fillList(Player.NO_CAMO);        // Perform the initial layout.        pack();    }