Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Cardlayout help

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Cardlayout help

    Hello everyone I am quite new to Java swing so bare with me.

    I am currently using the IDE netbeans 6.9. What I am trying to do is get a certain button to display a specific card from my card layout.

      @Action
        //action for button pan3
        public void changeIn() {
    CardLayout cl = (CardLayout)(mainPanel.getLayout());
    cl.show(mainPanel, card3);
        }


    That is my code right there; as you can see I am using the cl.show method. I have 3 jpanels inside a cardlayout. jpanel 3 has a name of card3. As you can see I am trying to have this specific card to show on the click of a button. This code shows no error however when I compile it and click the button
    nothing happens. Does anyone know how to get his to work?

    Thanks for the help I am very new to swing.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Cardlayout help

    Read this: How to Use CardLayout (The Java™ Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container)

    If that doesn't help, boil your problem down to an SSCCE (that's a link) that demonstrates the problem without any extra code.

Tags for this Thread