I have a class like this:
public class A {
public static void main() {
B f1 = new B();
f1.setVisible(true);
}
class B extends JFrame {
public B() {
JButton btn = new JButton("click me");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
C f2 = new C();
f2.setVisible(true);
}
});
add(btn);
}
}
class C extends JFrame {
public C() {
//whatever here
}
}
}
When I first run this java code, a window X contains a button "click me". After I click it, another new window Y is popped out. But the problem is that when I close the new window Y, the old window X is closed together with Y automatically. (i.e. they are closed at the same time)
What I wanna do is that after I close Y, X keeps there and not to be closed. How to do it?