This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Need Help for CardLayout. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Need Help for CardLayout." Watch "Need Help for CardLayout." New topic
Author

Need Help for CardLayout.

kei hosima
Greenhorn

Joined: Feb 23, 2003
Posts: 13
There is a CardLayout layout manager name clay and has been populated with 5 components whose identifiers are "A", "B", "C", "D", "E".
I don't know the order in which the components were added to the container.
I know, however, that the component with the identifier "B" is not the first component.
In such a case, how could I display the component that was added to the container prior to the one having the identifier of "B"?
I know there are 4 possible methods I could use
first(), last(), next(), and previous().
But how? How could I display the component that was added to the container prior to "B" if I don't know the order of the container?
I would appreciate your suggestion/advice/help.
Thanks in advance.
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Moving to Swing/AWT


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Chantal Ackermann
Ranch Hand

Joined: Sep 28, 2000
Posts: 508
you could keep track of the order yourself: when you create the panels you put the identifiers into a List which will preserve their order. the list allows you to retrieve the identifier using the index: list.get(list.indexOf("B") - 1);
chantal
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Need Help for CardLayout.
 
Similar Threads
AWT
buttons in card layout
The order of drawing seq. and component diag.?
Netbeans 5 : add component using addLayoutComponent() problem
Layout Qstn