Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
- frame.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
- setDefaultCloseOperation(DISPOSE_ON_CLOSE);
- public class AppMenuFileExit extends JMenuItem implements ActionListener
- {
- // do your normal menu item code here
- @Override
- public void actionPerformed(ActionEvent e)
- {
- WindowEvent we;
- we = new WindowEvent((Window) App.getFrame(), WindowEvent.WINDOW_CLOSING);
- App.getFrame().dispatchEvent(we);
- }
- }
- public class AppFrame extends JFrame implements WindowListener
- {
- // Do all the things you need to for the class
- @Override
- public void windowOpened(WindowEvent e)
- {}
- @Override
- public void windowClosing(WindowEvent e)
- {/* can do cleanup here if necessary */}
- @Override
- public void windowClosed(WindowEvent e)
- {
- dispose();
- System.exit(0);
- }
- @Override
- public void windowActivated(WindowEvent e)
- {}
- @Override
- public void windowDeactivated(WindowEvent e)
- {}
- @Override
- public void windowDeiconified(WindowEvent e)
- {}
- @Override
- public void windowIconified(WindowEvent e)
- {}
- }
- frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE)
- System.exit(home.EXIT_ON_CLOSE);
- frame.dispose();
- System.exit(0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement