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
No need to delete the object. The garbage collector will take care of the memory as soon as it is no longer referenced.