0

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.

Roberto
  • 167
  • 1
  • 3
  • 19

1 Answers1

1

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

Community
  • 1
  • 1
cghislai
  • 1,751
  • 15
  • 29