public class Scratch {
public static void main(String[] args) {
Dimension d = new Dimension(300,300);
JFrame frame1 = new JFrame("Frame-1");
JFrame frame2 = new JFrame("Frame-2");
frame1.setSize(250,250);
frame2.setSize(d);
frame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame2.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame1.setVisible(true);
frame2.setVisible(true);
}
}
When I run this, the two frames show up as expected, but when I close one of them, both of them close. I want to achieve the functionality where only the frame I click 'x' on closes and the other remains open until I click the 'x' on it. How do I do it?