How do I change a card panel in various places in my code.
The places I would like to add this action are in the following blocks of
code : a WindowEvent(windowClosing) , a method that is called when a button
is clicked, and an instanceof MenuItem.

After much stuggle with the CardLayout using AWT I have managed to add several
images to theCardLayout and can be display them with:
((CardLayout)cards.getLayout()).show(cards, anigif);
or ((CardLayout)cards.getLayout()).show(cards, guitargif);
The gui is a Frame to which images(to the default panel I guess) are painted
(to the default panel I guess), and a panel added (East) nesting 2 panels
using GridLayout. One of these nested panels is the card panel in question
(cards). A class displaying animated gifs used to display the gifs in their
respective panels :the first card is guitargif, the second is anigif.

My question is this, how do I adapt the code so that various
actions perform this ? It only seems to work with the constructor.
My code is probably 1.1 (?) and I am testing it using java 1.3.

I am have tried adding ((CardLayout)cards.getLayout()).show(cards, anigif);
to various places in the rest of the code, and though it compiles I get
a java.lang.NullPointerException upon execution. I have also tried it with
methods ie.
((CardLayout)cards.getLayout()).show(cards, anigif);//anigif is a String

The full code for the main class is at www.pathcom.com/~robertle/CardQuestion.html
with relevent code in bold.

Here is a fragment:
final static String anigif = "gif display";
final static String guitargif = "guitar pic display";
Panel pan;
Panel cards;
final static CardLayout cardLayout = new CardLayout();
cards.add(anigif, imcan);
guitar guitarPic = new guitar();//gif display class
cards.add(guitargif, guitarPic);//gif display class
((CardLayout)cards.getLayout()).show(cards, anigif);
pan.add("East", cards);

((CardLayout)cards.getLayout()).show(cards, anigif)
Many thanks,