This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hello, I am new to swing, and am having trouble on performing some object oriented functionality. I have two classes. When I hit the response button in testPanel, I want the testPanel to dissapear, and I want main to be notified of the change. Is there any way to do this?
Ok, so I learned how to use a container listener. Now I am trying to make this work, and while it compiles and runs, when the container listener goes off and removes the inner class, it fires a bunch of errors.
Chris, when do you get this exception? Immediately at the start? That would make sense if you add this listener to the container before you are done creating your GUI; if you add a component in the constructor while either main, clusterMain or panel is still null the listener will still be triggered. Don't add the listener until you are done building your GUI.
If it happens afterwards, make sure these three fields are not null. If your code needs to allow them to be null, surround the code with null checks: