Hi. I have an issue. That's given a snippet of class.

public constructor () // the start of constructor
{
 JPanel courseChooserPanel = new JPanel(card);  
        box.add(courseChooserPanel);

 CardLayout card = new CardLayout();  
 Department comp = Department.get("COMP");                               // refers to another class
        CourseChooser compPanel = new CourseChooser(this,comp); // refers to another class
        courseChooserPanel.add(compPanel, COMP); 
         card.show(courseChooserPanel,"compPanel");
}// the end of constructor

Why " card.show(courseChooserPanel,"compPanel"); " does not work; it does not produce any output. There is no error too.

For starters, I don't see how that would compile considering you instantiate JPanel with reference to 'card' before it is even initialized.

Secondly, you should add your CourseChooser component to 'card', not the parent JPanel 'courseChooserPanel'.

http://java.sun.com/docs/books/tutorial/uiswing/layout/card.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.