I have a problem with understanding the following code:
import java.awt.Dimension;
import java.awt.GridLayout;
import javax.swing.*;
public class A
{
public A(){
JFrame myframe = new JFrame ("hz window");
myframe.setLayout(new GridLayout ());
myframe.setSize(new Dimension (500, 200));
myframe.setVisible(true);
}
public static void main (String arg[]){
new A();
// System.gc(); //1
//Runtime.getRuntime().gc(); //2
}
}
The scope of myframe object is the constructor of class A,right?
Then, why is the window not dissapeared (i.e.,removed by garbage collector in lines 1 and 2)
What is the scope of all gui elements we create in java program?
Where does JVM keep all the links to the application's gui objects?
I'm sorry for newbie questions.