How to get a JPanel to make itself dissapear?
Howdy all. (Edit: I swear I know how to spell disappear)
I have a really simple app I'm trying to get going but, I've hit a wall.
I create a simple empty JFrame and display it. When it is displayed a small JPanel pops up asking you to hit one of two buttons:
"Okay" button to change the background color of the JFrame.contentPane to pink.
"Cancel" button to change nothing.
After either button is pressed I want the JPanel with the buttons to go away.
Currently, I have implemented this JPanel as a seperate class - ButtonPanel.
So, my question is: What can I do within this ButtonPanel to make the ButtonPanel go away? When in the ButtonPanel.actionPerformed(Event) method what can I do to make the ButtonPanel go away and possibly change the background color of the contentPane of the JFrame?
I thought about creating some sort of intermediate class to which I would pass an instance of the ButtonPanel. I would also pass an instance of this intermediate class to the ButtonPanel.
The intermediate class would have a method called "makeButtonPanelGoAway()" which could be called in the actionPerformed method of the ButtonPanel to get rid of the ButtonPanel.
However, I figure someone probably thought of a brighter way of handling this. Could anyone tell me a better way of doing what I want to do?
Thanks everyone. Just tell me if none of it makes sense and I'll try to clarify.