Inheritance and GUIs

We make our own Jframe, called MyJFrame

public class MyJFrame extends JFrame {

MyJFrame (String title){… title, size…

addWindowListener(new WindowCloser());

setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); }

public class WindowCloser extends WindowAdapter {

public void windowClosing (WindowEvenet event) {

int choice = JOptionPane.showConfirmDialog (MyJFrame.this,“Do you really want to quit:, “Confirm  quit”,JOptionPane.YES_NO_OPTION);

if (choice == JOptionPane.YES_NO_OPTION)

System.exit(0); }

}

}

Result à