Results 1 to 3 of 3
  1. #1
    tianchen is offline Member
    Join Date
    Jan 2014
    Posts
    34
    Rep Power
    0

    Default How to get the reference to the next card in CardLayout

    Hi everyone,

    I have such a problem. Suppose I have a cardLayout cl which is added by several cards ,say card1 card 2 card 3 card 4...... card n in order.
    These cards are showed sequentially, but for example, the behaviour on card 3 may have impact on the generation of card 4.

    My solution to this problem is:

    try to dynamically regenerate each card, for example, when the card 3 is finish processed by the user. After clicking on the "next" button card 4 is reloaded and showed.
    To implement this, I have to get the reference of card 4 on the position of card 3. Do you have idea, how this can be achieved?

    Or do you have any other suggestions on how I can handle this problem?

    Thank you very much for your time.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,618
    Rep Power
    5

    Default Re: How to get the reference to the next card in CardLayout

    Can't you just save the references to the cards in an array or map? Besides, the CardLayout just controls how the panels are laid out. I would assume you can still get the panels in the usual way from the parent component which contains them.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    tianchen is offline Member
    Join Date
    Jan 2014
    Posts
    34
    Rep Power
    0

    Default Re: How to get the reference to the next card in CardLayout

    Hi jim,
    you are right! It works now.
    Thank you for your suggestion. It really saves me from wasting a lot of time.

Similar Threads

  1. Replies: 4
    Last Post: 06-15-2012, 06:10 AM
  2. CardLayout Help
    By David M. in forum New To Java
    Replies: 4
    Last Post: 08-06-2011, 02:57 AM
  3. Help with CardLayout
    By Kyle227 in forum New To Java
    Replies: 4
    Last Post: 05-28-2010, 01:03 AM
  4. Question Card Layout, Card Management
    By lrichil in forum AWT / Swing
    Replies: 1
    Last Post: 04-22-2010, 10:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •