• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Need Help for CardLayout.

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to Swing/AWT
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
All of the following truths are shameless lies. But what about this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic