I'm working on a GUI assignment and I encountered a problem that I cannot figure out. I have a JFrame with multiple JPanels, one of those JPanels contains a CardLayout with multiple JPanels. Since we are more people working on the project we decided to make a separate class (that extends JPanel) for each panel that's gonna be inside the CardLayout.
The problem is accessing components of the JFrame from the JPanel classes.
To give you an example, I have a JLabel somewhere in the JFrame that serves as a status bar and I want to change the text of the status bar when a button is pressed on the SaleMain panel (a class SaleMain that extends JPanel, contained in the CardLayout).
Another example, inside another panel EditCustomer (also a JPanel class, included in the CardLayout), I'd like to have a button with an action listener that will change the current panel (the one containing the button) to a different panel from the CardLayout.
Hope I made it as clear as possible, thank you guys in advance for helping me :)
this
. Then you define the getters for each of these components. When you want to modify a GUI component you execute something likemanagerObj.getPanel1().method()
– GeorgeG