I am experimenting with Cardlayout and have hit a snag. I hope I can explain this so it is understandable.
I have three (for now) JPanels that are added to the Cardlayout and I can switch between them using menu items and buttons on the Toolbar of the JFrame. These JPanels are classes created using NetBeans GUI designer (each panel is a different Class). The contents of the Panels (cards) are set by the constructor of the Panel; for example a text field in the panel has the value set at time of panel construction.
MY QUESTION is how do I set values when a panel (card) is displayed? These panels will eventually be database record data entry & edit screens. So, when a card is displayed it will need to access a database and populate fields from the result set.
Can I create a method of the Panel that gets control when the Panel becomes active (top card, visible, etc.)? I tried adding a ComponentListener for when a panel is shown, but that didn't work (get control). Can I call a method of the Panel's Class in the button action that switches panels (cards)? If so, how? I can't seem to find the right code to access a public method of the Panel class from the Class of the main Frame.
Hope you understand what I'm asking and can help.
Thanks, Jim