URL resource = null;
/** Load respective images based on card type */
Card card = iter.next();
if(card instanceof WeaponCard)
{
WeaponCard weaponCard = ((WeaponCard)card);
switch(weaponCard.getWeaponType())
{
case CANDLESTICK:
resource = Main.class.getResource("/clueless/main/resources/weapons/Candlestick_card.gif");
break;
case KNIFE:
resource = Main.class.getResource("/clueless/main/resources/weapons/Knife_card.gif");
break;
case LEAD_PIPE:
resource = Main.class.getResource("/clueless/main/resources/weapons/Pipe_card.gif");
break;
case REVOLVER:
resource = Main.class.getResource("/clueless/main/resources/weapons/Revolver_card.gif");
break;
case ROPE:
resource = Main.class.getResource("/clueless/main/resources/weapons/Rope_card.gif");
break;
case WRENCH:
resource = Main.class.getResource("/clueless/main/resources/weapons/Wrench_card.gif");
break;
}
/** get URL to image */
try {
buttonIcon = ImageIO.read(resource);
} catch (IOException e) {
// TODO Auto-generated catch block
System.err.print(e.toString());
}
//Scale it to the UI size
ImageIcon icon = new ImageIcon(buttonIcon.getScaledInstance(96, 150, 0));
//Instantiate image button
WeaponButton button = new WeaponButton(icon, weaponCard.getWeaponType());
button.setBorder(new LineBorder(Color.BLACK, 5));
button.setBorderPainted(true);
//add actionEvent to Button
button.addActionListener(new SelectCard());