This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
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
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply 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://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: button in jpanel should change background of jframe?
 
Similar Threads
Message dialog box displaying behind the main frame
JFrames and JPanel
JLayeredPane in JPanel?
changing background color of JFrame
set picture as background of JFRAME and JPanel