Java Swing - How to access a JComponent of one JPanel from other JPanel, both added to the JFrame?
Posted
by Yatendra Goel
on Stack Overflow
See other posts from Stack Overflow
or by Yatendra Goel
Published on 2010-04-26T12:56:11Z
Indexed on
2010/04/26
13:03 UTC
Read the original article
Hit count: 184
I am developing a Java Desktop Application with GUI implemented in SWING.
I hava a JFrame
. I have added three JPanel
s 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?
© Stack Overflow or respective owner