You have to use jframe and then
JFrame AFrame = new JFrame("Frame with components");
AFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
But if you insist on Frame, add a listener:
AFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
source
share