Hello guys, Say If i have two classes, in each class is a different JFrame, e.g JFrame A and JFrame B ( in seperate classes).
Now from the constructor of JFrame A I may push a button with an actionlistener attached, which will instantiate the other class, thus creating JFrame B. The problem is when JFrame B is created, both the JFrames are visible. If i close JFrame B, then JFrame A closes as well. How can i make it so only JFrame B closes?
Thanks
edit DISPOSE_ON_CLOSE
does not work for me, it closes all the jframes.
some sample code:
public class classone {
public classone() {
JFrame a = new JFrame("this is A");
classtwo newFrame = new classtwo();
}
}
public class classtwo {
public classtwo() {
Jframe b = new JFrame("this is B");
b.setDefaultCloseOperation(b.DISPOSE_ON_EXIT);
}
}
please ignore any syntax errors, just for demonstration.