* @param event - the <code>ItemEvent</code> of the camo selection.
*/
public void itemStateChanged(ItemEvent event) {
// Get the player that needs to be updated.
Player player;
if (chatLounge != null) {
player = chatLounge.getPlayerListSelectedClient().getLocalPlayer();
} else {
player = localPlayer;
}
// Get the camo image, category, and name that was selected.
Image image = (Image) event.getItem();
String category = dialog.getCategory();
String itemName = dialog.getItemName();
// If the image is null, a color was selected instead.
if (null == image) {
for (int color = 0; color < Player.colorNames.length; color++) {
if (Player.colorNames[color].equals(itemName)) {
BufferedImage tempImage = new BufferedImage(80, 72, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = tempImage.createGraphics();
graphics.setColor(PlayerColors.getColor(color));
graphics.fillRect(0, 0, 84, 72);
butCamo.setIcon(new ImageIcon(tempImage));
player.setColorIndex(color);
break;
}
}
itemName = null;
}
// We need to copy the image to make it appear.
else {
// Update the butCamo's image.
butCamo.setIcon(new ImageIcon(image));
}
// Update the local player's camo info.
player.setCamoCategory(category);
player.setCamoFileName(itemName);
// Send a message to a server, if called for.
if (chatLounge != null) {
chatLounge.getPlayerListSelectedClient().sendPlayerInfo();
}