Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  2.  
  3. frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
  4.  
  5. frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
  6.  
  7. setDefaultCloseOperation(DISPOSE_ON_CLOSE);
  8.  
  9. public class AppMenuFileExit extends JMenuItem implements ActionListener
  10. {
  11. // do your normal menu item code here
  12.  
  13. @Override
  14. public void actionPerformed(ActionEvent e)
  15. {
  16. WindowEvent we;
  17. we = new WindowEvent((Window) App.getFrame(), WindowEvent.WINDOW_CLOSING);
  18.  
  19. App.getFrame().dispatchEvent(we);
  20. }
  21. }
  22.  
  23. public class AppFrame extends JFrame implements WindowListener
  24. {
  25. // Do all the things you need to for the class
  26.  
  27. @Override
  28. public void windowOpened(WindowEvent e)
  29. {}
  30. @Override
  31. public void windowClosing(WindowEvent e)
  32. {/* can do cleanup here if necessary */}
  33.  
  34. @Override
  35. public void windowClosed(WindowEvent e)
  36. {
  37. dispose();
  38. System.exit(0);
  39. }
  40. @Override
  41. public void windowActivated(WindowEvent e)
  42. {}
  43. @Override
  44. public void windowDeactivated(WindowEvent e)
  45. {}
  46. @Override
  47. public void windowDeiconified(WindowEvent e)
  48. {}
  49. @Override
  50. public void windowIconified(WindowEvent e)
  51. {}
  52. }
  53.  
  54. frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
  55.  
  56. System.exit(home.EXIT_ON_CLOSE);
  57.  
  58. frame.dispose();
  59. System.exit(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement