wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes button in jpanel should change background of jframe? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "button in jpanel should change background of jframe?" Watch "button in jpanel should change background of jframe?" New topic
Author

button in jpanel should change background of jframe?

Chris Song
Greenhorn

Joined: Jan 29, 2005
Posts: 2
Hello I have created 2 classes

First class is a jpanel and it has a button

Second class is a jframe and displays an object of jpanel.

I wrote this program so that i can understand object oriented programming.

My question is How can i change the jframe background colour by clicking the button that is in the jpanel class?

Could somebody provide me with a similar example. I would really apreciate it.

Thanks
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
this changes the color of the containing JPanel of the main class, not the
JFrame itself.

I've included 2 ways
1) passing a reference of the parent class to the child class
2) just using getParent()

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: button in jpanel should change background of jframe?
 
Similar Threads
JLayeredPane in JPanel?
set picture as background of JFRAME and JPanel
changing background color of JFrame
Message dialog box displaying behind the main frame
JFrames and JPanel