garbage collector for JFrame's object

后端 未结 3 2049
抹茶落季
抹茶落季 2021-01-23 20:44
import javax.swing.*;

public class Main
{
    public Main()
    {
        JFrame jf = new JFrame(\"Demo\");
        jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          


        
3条回答
  •  我在风中等你
    2021-01-23 21:22

    The frame is visible and the reference to the object is reachable by at least one of the GUI threads (the Event Dispatch Thread). That is why it isn't garbage collected.


    If you want it to disapear, use frame.dispose().

提交回复
热议问题