Card Confusion
posted 24 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I have a litle confused concerning the CardLayout manager. Many books show code where an anonymous instance to a Layout Manager is created. For example suppose F is an instance of a Frame. To set the layout manager to FlowLayout we could write:
setLayout(new FlowLayout());
And I have found some instances where this is done with the CardLayout manager. HOWEVER, since the actual methods for showing the panels belong to the instance of CardLayout and not the container component, writing:
setLayout(new CardLayout());
is entirely self defeating since we wouldn't be able to call the various methods for displaying the "cards", eg. first, prev, next ... etc.
Am I right here, and the books are wrong - or is it (more likely) the other way around?
Thanks in advance
Dan
setLayout(new FlowLayout());
And I have found some instances where this is done with the CardLayout manager. HOWEVER, since the actual methods for showing the panels belong to the instance of CardLayout and not the container component, writing:
setLayout(new CardLayout());
is entirely self defeating since we wouldn't be able to call the various methods for displaying the "cards", eg. first, prev, next ... etc.
Am I right here, and the books are wrong - or is it (more likely) the other way around?
Thanks in advance
Dan
posted 24 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Well, it's possible to recover the layout manager later using the getLayout() method on whatever object you used setLayout() on. Of course, to access the CardLayout-specific methods, you need to cast the layout to CardLayout. I'd be more inclined to keep a copy in the first place, as you suggest.
"I'm not back." - Bill Harding, Twister
Dan Temple
Ranch Hand
Posts: 93
posted 24 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
That makes sense. Thanks for the help!
Dan
Dan
| No one can make you feel inferior without your consent - Eleanor Roosevelt. tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |










