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:
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
((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";
final static CardLayout cardLayout = new CardLayout();
guitar guitarPic = new guitar();//gif display class
cards.add(guitargif, guitarPic);//gif display class
Re: cardLayout question
note: I have moved servers and the pathcom web and email address is no longer
valid. If you would like to help and need to see more code please email
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL