I am developing a Java Desktop Application with GUI implemented in SWING.
I hava a JFrame. I have added three JPanels on that. One JPanel panel1 has a Start Button. Now I want to disable various componets on other JPanels when a user presses the start button on the panel1.
Now how can I access the components of those other panels from panel1.
I know that one approach is to first get the container of panel1
panel1.getParent();
Then get the components of the container
container.getComponents();
and use them as per need.
Q1. Is there any other way by which I can perform the same task? (I think this is the only way)
Q2. After getting the components list of the container, how to differentiate one container with other?
You can make instance variables that reference the panels when you create them, and use those variables to reference the panels.