X-Git-Url: http://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=src%2Ftim%2Fprune%2Fcorrelate%2FCardStack.java;fp=src%2Ftim%2Fprune%2Fcorrelate%2FCardStack.java;h=555c5449d141afe46afda5735bb4511c4dcc68b3;hp=0000000000000000000000000000000000000000;hb=ce6f2161b8596f7018d6a76bff79bc9e571f35fd;hpb=2d8cb72e84d5cc1089ce77baf1e34ea3ea2f8465 diff --git a/src/tim/prune/correlate/CardStack.java b/src/tim/prune/correlate/CardStack.java new file mode 100644 index 0000000..555c544 --- /dev/null +++ b/src/tim/prune/correlate/CardStack.java @@ -0,0 +1,64 @@ +package tim.prune.correlate; + +import java.awt.CardLayout; +import java.awt.Component; + +import javax.swing.JPanel; + +/** + * Panel to act as a card stack + */ +public class CardStack extends JPanel +{ + private int _numCards = 0; + private int _currCard = 0; + private CardLayout _layout = null; + private static final String cardName = "card"; + + /** + * Constructor + */ + public CardStack() + { + _layout = new CardLayout(); + setLayout(_layout); + } + + /** + * Add a card to the stack + * @param inComponent component to add + */ + public void addCard(Component inComponent) + { + super.add(inComponent, cardName + _numCards); + _numCards++; + } + + /** + * @return current card index, starting from 0 + */ + public int getCurrentCardIndex() + { + return _currCard; + } + + /** + * @return number of cards in the stack + */ + public int getNumCards() + { + return _numCards; + } + + /** + * Show the specified card + * @param inIndex index of card, starting from 0 + */ + public void showCard(int inIndex) + { + if (inIndex >= 0 && inIndex < _numCards) { + _currCard = inIndex; + _layout.show(this, cardName + inIndex); + } + } +}