I want to link button on a card(JPanel) in a cardLayout to another card(JPanel) in the same Layout.
i Have 2 Panel class = 1. welcome.class , snacks.class
and 1 jframe class = kiosk.class
Already i can switch through view using the flowLayout but i want to link a button from one card to the other
What i want to achieve is how to use a button on welcome panel and navigate to the snack panel within a cardLayout
This is what i tried
KIOSK CLASS(JFRAME CONTAINING VIEWS)
The main connection is highlighted in dark red
What i was trying to do is to define a new kiosk in my welcome class and reference the switchPanel method which takes a parameter of (Container container, String plName)
panelCard is the parent holding my card views, so therefore before i can create a button link on a card to link to the other i have to access a parent through which i can access the child card. so i want access the panelCard object in Kiosk in my welcome.class
So Welcome is one panel of a CardLayout and kiosk (should be Kiosk) is another?
I would suggest a controller that sits above these two.
Neither of these classes should know that it is part of a CardLayout. They should just have a reference to something that will handle an event that means the screen needs to change.
So, when the relevant button is pressed, this will inform the controller which will then handle the CardLayout changes.
Something like the above is the concept.
That way you detach the two screens.