I have created a class which has a panel named cards and its layout is CardLAyout. I have added card items. In this class I want to create a separate method by calling which, layout switches to next card.
import java.awt.CardLayout;
import java.awt.Container;
public class cards
{
public Container cards;
//creating objects for other classes
public cricGUI gu;
public cricMainMenu mm;
public void cardsList()
{
cards = new Container();
cards.setLayout(new CardLayout());
//adding panels and contentPanes from other classes.
mm = new cricMainMenu();
gu = new cricGUI();
cards.add(mm.contentPane);
cards.add(gu.pane);
}
public void getNextCard(Container x)
{
}
}
So as u can see I have panels on other classes that I have added to my cards. what i want to do is create getNextCard() method which takes the currently active panel as its arguements. when i call this function it should switch the currently active panel with the next one in my CardLayout list. How can i do this? Thanks