permaculture playing cards
The moose likes Java in General and the fly likes CardLayout contents not available Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "CardLayout contents not available" Watch "CardLayout contents not available" New topic

CardLayout contents not available

Brian Coates
Ranch Hand

Joined: Jul 03, 2001
Posts: 42
I'm writing a wizard that will end up running on different platforms, and I'd like each platform to have its "own" wizard.. which I've done using CardLayouts. Right now, I've just created all the CardLayouts I may need within my main java file. Then I test for what OS I'm on, and go with the appropriate CardLayout.
What I'd like to be able to do is have a seperate class for each platform's wizard within a package(ie: com.brian.os would contain, com.brian.os.linux, and so on). I have each of those classes extending the java.awt.Container class, and I define the necessary panels and add them into the layout. However, when I create a new instance of that class in the main java file, I don't "see" any of the components of the container. How do I get to them?
thanks in advance,
(Using the debug system.out.println's, I see that when oc is initially created, the println in its contructor shows there are 2 elements. Then the println shows there are 0. In add(), it shows there are 3.)
code snippits...
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
Couple of comments:
First - it is a REALLY bad idea to name a class Main - unless you are trying to tick off the next guy that has to look at you code - like me for instance.
Next, when you make the Main (which is a Frame) object visible, everything that it contains becomes visible also. So you have a bunch of setVisibles in there that don't do anything.
After that I am really confused. Which of these are you executing? They don't seem to relate to each other in any meaningful way?

"JavaRanch, where the deer and the Certified play" - David O'Meara
Brian Coates
Ranch Hand

Joined: Jul 03, 2001
Posts: 42
That class isn't really named, I just called it that here to distinguish the "main" java class from the other. I'll change it.. It also looks like I messed up copy & pasting. So here's a (hopefully) better explanation, and cleaner code.
In order to have an OS-specific wizard for various OS's (Ie, one for windows, a seperate one for Linux, a seperate one for Solaris), I wanted to try and create a class for each wizard. (Below is the windows class, which contains the two panels I would want in my wizard for windows.) Then in my main class (Wizzy), I could just check for the OS and create an instance of the appropriate class... thus giving me the wizard (panels in a container using CardLayout as the layout).

I agree. Here's the link:
subject: CardLayout contents not available
It's not a secret anymore!