Example #1
0
 /**
  * Removes a list of CardButtons from a JComponent
  *
  * @param list the list of CardButtons to be removed
  * @param fromWhere the JComponent to remove the CardButtons from
  */
 private void removeCardButtons(List<CardButton> list, JComponent fromWhere) {
   for (CardButton button : list) {
     fromWhere.remove(button);
     cardButtonMap.remove(button.getCard());
   }
   fromWhere.revalidate();
   validate();
 }
Example #2
0
 /**
  * Creates a CardButton and adds it to the cardButtonMap
  *
  * @param card the card which the CardButton illustrates
  * @return the created CardButton
  */
 private CardButton createCardButton(Card card) {
   CardButton button = new CardButton(card);
   button.setVisible(true);
   button.setPreferredSize(new Dimension(48, 80));
   button.addActionListener(new CardButtonListener(this, card, button));
   cardButtonMap.put(card, button);
   return button;
 }
Example #3
0
 /** Updates the displayed CardButtons, moving them from the mainWindow to the pileWindow */
 public void preTurn() {
   List<Card> pileCards = pile.getCards();
   List<CardButton> toBeRemoved = new ArrayList();
   for (CardButton button : cardButtonMap.values()) {
     if (pileCards.contains(button.getCard())) {
       toBeRemoved.add(button);
       createCardGraphics(button.getCard(), pileWindow).setToPile(true);
     }
   }
   removeCardButtons(toBeRemoved, mainWindow);
 }
  @Test
  public void testBoardCardContainLargeIconOfCard() {
    CardButton[] buttons = boardPanel.getButtons();
    cardButton = buttons[0];

    Card card = cardButton.getCard();

    String path = cardButton.getIconPath() + (card.getRevertedName() + ".gif");
    java.net.URL imgURL = getClass().getResource(path);
    ImageIcon icon = new ImageIcon(imgURL, card.toString());

    assertTrue(
        "button have large image icon",
        ((ImageIcon) cardButton.getIcon()).getImage().equals(icon.getImage()));
  }
Example #5
0
 /** Hides and disables all CardButtons */
 public void hideCardSprites() {
   for (CardButton sprite : cardButtonMap.values()) {
     sprite.setFaceUp(false);
     sprite.setEnabled(false);
   }
 }