1 package tim.prune.correlate;
3 import java.awt.CardLayout;
4 import java.awt.Component;
6 import javax.swing.JPanel;
9 * Panel to act as a card stack
11 public class CardStack extends JPanel
13 private int _numCards = 0;
14 private int _currCard = 0;
15 private CardLayout _layout = null;
16 private static final String cardName = "card";
23 _layout = new CardLayout();
28 * Add a card to the stack
29 * @param inComponent component to add
31 public void addCard(Component inComponent)
33 super.add(inComponent, cardName + _numCards);
38 * @return current card index, starting from 0
40 public int getCurrentCardIndex()
46 * @return number of cards in the stack
48 public int getNumCards()
54 * Show the specified card
55 * @param inIndex index of card, starting from 0
57 public void showCard(int inIndex)
59 if (inIndex >= 0 && inIndex < _numCards) {
61 _layout.show(this, cardName + inIndex);