I created a dialog with a jpanel inside it, and that jpanel will be still referenced if I get rid of the dialog. I want to destroy that dialog and everything in it when I click
There is no need to destroy object in Java in the way like in C++.There is garbage collector which destroys(release memory used by) objects automatically after there is no references to this object in running code. Everything that you can do is to force destroy link by Object obj = null;
This kills reference to obj.