Results 1 to 3 of 3
- 11-26-2011, 08:02 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 17
- Rep Power
- 0
JFrame making it do an action on exit
Hello,
I want to make my program do something else than
How do i call a class from another java file when pressing the X?Java Code:frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
I've already made a file that looks like this:
All i need is to make the Exit Button execute that.Java Code:public class Exit { private static Main mainfile = new Main(); public void onexit() { if (mainfile.fn.equals("unnamed")) { Object[] options = { "SAVE", "NO", "CANCEL"}; JOptionPane.showOptionDialog(null, "Do you want to save " + mainfile.fn + "?", "Warning", JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]); } else { mainfile.frame.dispose(); } } }
- 11-26-2011, 08:09 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,605
- Rep Power
- 5
Re: JFrame making it do an action on exit
- 11-26-2011, 08:29 PM #3
Member
- Join Date
- Nov 2011
- Posts
- 17
- Rep Power
- 0
Similar Threads
-
HTTP Status 404 - There is no Action mapped for namespace / and action name
By kurakukiran in forum Web FrameworksReplies: 1Last Post: 06-30-2011, 09:49 AM -
How do I stop the program but not exit the JFrame?
By rajkobie in forum New To JavaReplies: 1Last Post: 04-23-2011, 03:53 PM -
Could not find main class: Jframe. Program will exit.
By egbert95 in forum New To JavaReplies: 4Last Post: 07-29-2010, 02:53 PM -
Could not find main class: Jframe. Program will exit.
By egbert95 in forum Advanced JavaReplies: 8Last Post: 07-29-2010, 02:53 PM -
Making a JApplet into a JFrame into a .jar
By aqualicy in forum Java AppletsReplies: 2Last Post: 05-14-2010, 04:29 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks