How do I delete an object referenced by a dialog?

后端 未结 8 2469
独厮守ぢ
独厮守ぢ 2021-02-14 11:42

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

8条回答
  •  Happy的楠姐
    2021-02-14 12:26

    You meant "how" to destroy it? There is no way to destroy an object explicitly in Java. garbage collector in Java automatically reclaims the memory occupied by it If there is no reference of the same exists.

    "but I create dialog with jpanel inside it, and that jpanel will be still referrenced. I want to destroy that dialog when click my own button "Cancel"

    Just try setting that JPanel object to null or call the dispose method on it if that is available.

提交回复
热议问题