garbage collector for JFrame's object

后端 未结 3 2016
抹茶落季
抹茶落季 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

    When a JFrame is created, it registers itself in some internal Swing data structures which allow it to receive events like mouse clicks. This means there is a reference to your object lurking somewhere until you tell Swing to get rid of the window using dispose().

提交回复
热议问题