Reputation: 178
I have a JPanel (panelOne) on a JFrame (frame). On the panelOne I have two buttons and I like to, If I pushing one button the JPanel will change to another. But how? I can't access the frame from panelOne.
Upvotes: 0
Views: 98
Reputation: 1801
You have access to the whole tree of components from a Component.
See Java/Swing: Obtain Window/JFrame from inside a JPanel to get the top most ancestor. Also have a look at the Component javadoc: http://docs.oracle.com/javase/7/docs/api/java/awt/Component.html
Upvotes: 1