How to stop frame from closing in windowClosing event ?

I have an application which will download some files from the web.
If the user attempts to close the applicaiton and if some files donwload action is in progress then i need to warn the user and prevent the window from closing. This is what i have done. But what happens is message box is displayed and my window is getting closed. How to get rid of this ? need your help...
frame.addWindowListener(new WindowAdapter() {
               public void windowClosing(WindowEvent we) {
                    if(DownloaderGUI.tableModel.isSomeThingDownloading()) {
                         JOptionPane.showMessageDialog(null,"cannot close when something is downloading");
                         return;
                    System.out.print("closing..");
                    backEndThread.setCanQuit(true);
                    cleanUp();
                    System.exit(0);
          });

I have also done a similar things but still window is getting closed.
public void actionPerformed(...)
if(!canquit) {
      return;
} else {
      System.exit(0);
}Message was edited by:
chaos_begins_here

Similar Messages

  • How to stop frame from closing?

    Hi,
    ramka.addWindowListener(new WindowAdapter()
                  public void windowClosing(WindowEvent e)
                      Object [] qqq = {"yes", "no"};
                      int answer = JOptionPane.showOptionDialog(
                                null,
                                 "want to close window?",
                                 JOptionPane.YES_NO_OPTION,
                                  JOptionPane.QUESTION_MESSAGE,
                                  null,
                                 qqq,
                                 qqq[1]);
                      if (answer == JOptionPane.YES_OPTION)
                           // WHAT TO DO TO STOP WINDOW FROM CLOSING?
                  });as you can see above i want to stop frame from closing.
    what should i do in the commented line?
    or maybe somewhere else?
    please help,
    thanks

    Hello friend,
    I've found a solution for your query. I think, you'll get a solution from my codings. I've given you below my codings,plz go through it.Verify it. Reply me about my codings.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.JOptionPane;
    public class MyFrame extends JFrame{
         JButton jb=new JButton("My Details");
         public MyFrame(){
         JPanel jp=new JPanel();
         jp.add(jb,new FlowLayout(FlowLayout.CENTER));
         add(jp);
         jb.addActionListener(new ActionListener(){
         public void actionPerformed(ActionEvent ae){
                   if(ae.getSource()==jb){
                        String str[]={
                             "Name : Karthikeyan.K",
                             "Email-ID : [email protected]"
                        JOptionPane.showMessageDialog(null, str);
    WindowCloser wc=new WindowCloser();
    addWindowListener(wc);
         class WindowCloser extends WindowAdapter{
              public void windowClosing(WindowEvent we){
                   int res=JOptionPane.showConfirmDialog(null,"Do you want to exit from it?","Confirmation!!!",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE);
                   switch(res){
                        case JOptionPane.YES_OPTION:
                             dispose();
                             System.exit(0);
                             break;
                        case JOptionPane.NO_OPTION:
                             repaint();
                             doOpenFrame();
                             break;
                        case JOptionPane.CANCEL_OPTION:
                             repaint();
                             doOpenFrame();
                             break;
                        case JOptionPane.CLOSED_OPTION:
                             repaint();
                             doOpenFrame();
                             break;
         public static void doOpenFrame(){
              MyFrame mf=new MyFrame();
              mf.pack();
              mf.setSize(400,400);
              mf.setVisible(true);
         public static void main(String ar[]){
         doOpenFrame();
    }

  • How to stop mozilla from closing multiple intenet screens, when I only want to close one?

    I switched from Internet Explorer to Firefox. I often have more than one internet screen open. When I go to close one of them, Firefox sends me a message like, "You are about to close 3 tabs." When I tell it to close, I lose all 3 internet screens. I only want to close one. How can I stop that?

    Can you attach a screenshot?
    *http://en.wikipedia.org/wiki/Screenshot
    *https://support.mozilla.org/kb/how-do-i-create-screenshot-my-problem
    Use a compressed image type like PNG or JPG to save the screenshot.
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do NOT click the Reset button on the Safe Mode start window.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    You can try to open a new windows via Ctrl+N and use that window instead.
    See also:
    *http://kb.mozillazine.org/Prevent_websites_from_disabling_new_window_features

  • How to stop frame from compressing

    Ok... I'm still using GoLive.
    I have a page with three frames. One across the top.
    One "content" frame on the right, and one menu frame on the left.
    The menu frame is set to be 200- pixels.
    But when you drag the whole window to the left, the content window
    goes over the menu window, obscuring it.
    How do I make the menu frame stay 200 pixels and not be covered up.

    Thanks for the response.
    Here's what I think you want.
    </head>
    <frameset rows="149,*" border="0" frameborder="0" framespacing="0">
    <frame name="Header" src="web-content/header_title.html" noresize scrolling="no">
    <frameset cols="200,800" border="0" frameborder="0" framespacing="0">
    <frame name="Menu" src="web-content/genres.html" noresize scrolling="no">
    <frame name="Content" src="web-content/welcome_page.html" noresize>
    </frameset>
    <noframes>
    <body bgcolor="#ffffff">
    <p></p>
    </body>
    </noframes>
    </frameset>

  • How to stop browser from closing

    My Blackberry locks screen after 15 minutes idle time (adjustable between 1 and 15 minutes in Options|Security|Password). If the Blackberry web browser is opened to a web page and sits idle, after 15 minutes' screen lock and re-logon, the browser no longer shows the page left opened earlier. Can this be worked around? Opera Mini doesn't have this problem. Thanks.
    I've used multiple Blackberries of various versions. All behave the same. My current one is Torch 9810, version 7.1.

    My Blackberry locks screen after 15 minutes idle time (adjustable between 1 and 15 minutes in Options|Security|Password). If the Blackberry web browser is opened to a web page and sits idle, after 15 minutes' screen lock and re-logon, the browser no longer shows the page left opened earlier. Can this be worked around? Opera Mini doesn't have this problem. Thanks.
    I've used multiple Blackberries of various versions. All behave the same. My current one is Torch 9810, version 7.1.

  • Jpopup menu : Stopping it from closing ?

    What makes (mecanism) a popup menu close. Where in the model or in the hirarchy is it done. How do we intercept it and stop it from closing?

    My guess would be for you to extend the individual JMenuItem's and to override the methods:
    fireActionPerformed(ActionEvent event),
    fireItemStateChanged(ItemEvent event),
    fireStateChanged()
    Then add your own MouseListener to detect the mouse clicks and close at will.

  • I have itunes set up to sync with my Ipod Touch and my Ipad.  As of today, it keeps looking for an iPhone to sync with and give me an error message.  I don't have an iPhone and don't know how to stop it from popping open with this error message.

    I have Itunes set up to sync with my Ipod touch and Ipad.  As of today, iTunes has started searching to sync with an iPhone, which I don't have and pops open with an error message stating it cannot locate the iPhone to sync.  I have looked in devices and only the iPad and iPod Touch are listed.  Any ideas on how to stop iTunes from searching for any iPhone it is never going to find? It is annoying to have it popping up all the time with the error message.  Thanks in advance for any suggestions.

    You should really read the manual.
    "How do you restore from backup? "
    Restore.  When given the choice, choose to use backup.
    "And how can I check to see if the pics and videos are on my computer somewhere first??"
    They would only be where you put them.  What program did you use to import them?  Pics/vids taken with ipod are not part of the sync process at all.  You should be importing them just as you would with any digital camera.
    If you did not import them, then they are not on your computer.

  • How to stop Firefox from checking for add-on compatibility every time it opens?

    How to stop Firefox from checking for add-on compatibility every time it opens?

    That can be a problem with the compatibility.ini file in the Firefox profile folder.
    Try to rename (or delete) the compatibility.ini file in the Firefox profile folder to see if that helps.
    You can use this button to go to the currently used Firefox profile folder:
    *Help > Troubleshooting Information > Profile Directory: Show Folder (Linux: Open Directory; Mac: Show in Finder)
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    You can also check for problems with preferences.
    Delete possible user.js and numbered prefs-##.js files and rename (or delete) the prefs.js file to reset all prefs to the default value including prefs set via user.js and prefs that are no longer supported in the current Firefox release.
    *http://kb.mozillazine.org/Preferences_not_saved
    *http://kb.mozillazine.org/Resetting_preferences

  • I find very annoying that, although the cursor is flashing in the serch box, unless that box has been clicked in to enable it, typing goes to the nearest topic in the bookmark list. how to stop it from happening?

    i use Google home page as my firefox home page. often i find that although the cursor is flashing in the serch box, unless that box has been clicked in to enable it, typing goes to the nearest topic in the bookmark list instead of accepting the typing. how to stop it from happening? why not stop the cursor from appearing in the search box unless you have clicked in it?

    Do you organise your email into separate folders, or do you just let it accumulate in the Inbox?
    I would strongly advise you not to let it sit in the Inbox.
    When you see this happening, try right-click on the affected folder, select '''Properties''' then '''Repair Folder'''.
    Large folders (actually, a folder in Thunderbird is stored as a file, so it is sensitive to file size limits set by the underlying file system) can be problematic. This is one reason not to let messages collect in one folder. I use Thunderbird's Archive folders so that accumulated mails over several years can happily coexist because they are effectively stored in many small folders. No single mail store folder then exceeds the 2GB or 4GB sizes that have been known to stress the OS. I appreciate that current builds of Thunderbird and a modern 64-bit OS should be able to cope, but practically I find it slows down when given huge files, so I err towards a pragmatic solution; a large number of not very big files.
    Archives are searchable, and a Saved Search folder can give you a virtual composite folder allowing access to the entire Archive.

  • How to stop mail from recovering a too large message

    how to stop mail from recovering a too large message

    You can't stop Mail from storing sent messages locally. If they're synchronized with the IMAP server, they'll still be present locally. The only way to get the effect you seem to want is to use webmail.

  • How to stop mail from recovering the same message over and over again to the extent that it has wiped out all start up disk memory?

    How to stop mail from recovering the same message over and over again to the extent that it has wiped out all start up disk memory?

    You need to find and delete (move to the Trash) the offline mail cache (.offline cache.) It's a hidden folder (files and folders with a preceding dot are hidden) inside the Mail folder (inside IMAP) in your user library. Since it's hidden, in order to see it run the following command in Terminal in Applications>Utilities. Hit return/enter once you have pasted in the command.
    defaults write com.apple.finder AppleShowAllFiles -bool true ; killall Finder
    To reverse this and hide all those hidden files and folders again
    defaults write com.apple.finder AppleShowAllFiles -bool false ; killall Finder
    Leave hidden files/folders enabled until you finish emptying the Trash so you know it's gone.

  • How to stop Mail from selecting addresses from the list of Previous Recipients?

    How to stop Mail from selecting addresses from the list of Previous Recipients?

    This is a related question.
    I deleted ALL my previous recipients and when I create a new e-mail it STILL is getting addresses that I don't want - they pop up and I don't know how to stop this!
    I switched from one ISP to another - I deleted the old e-mail account in MAIL - I DID use the same name on the account - is that why it keeps bringing up the old address? 
    ARGH!

  • How to stop iPhoto from opening each time I add a photo using Yosemite

    How to stop iPhoto from opening each time I add a photo using Yosemite

    Add image to iPhoto Library
    From where.  I don't think you can keep it mininmized when importing because if it runs into a duplicate it will present a warning window for you to make a decision in. Therefore, it will always be open when importing.
    You can send a feature request to Apple via http://www.apple.com/feedback/iphoto.html.

  • HT3702 Can anyone tell me how to stop zoosk from taking money out of my account

    Can anyone tell me how to stop zoosk from taking money out of my account I want to close the account they told me I have to close it through iTunes I do not have a PC to go online with just my iPhone please help I need to stop this money from coming out of my account I cannot afford it

    If this is a subscription, see:
    http://support.apple.com/kb/HT4098
    Regards.

  • How to stop iphone from autoplay when plug into car audio system usb?

    how to stop iphone from autoplaying when connected to your car audio USB ?

    You need to remove the association that Windows has with that particular file type. To do that, you need to open Windows Explorer. From there, click on Tools, then Folder options. Click on the tab that is named file types. You then need to find the extension for the photos that appear in the iPhone, then click that registered file type. Once you do that, there is a section to select the program to open that file type with. You can click on the change button, and that will allow you to change the program that it opens with, or restore the default. There is also a box that can be checked to always use the selected program. If you unselect it, it will prompt you next time on what program to use.
    Hope this helps.

Maybe you are looking for

  • Reg:field and table name

    Hi Guys, I am developing one report for knowing the recognised amount ,but i am not able to get the field and table name .In system it is showing that VBRAV51HD:RVAMT_REAL_G.But this is a structure,how to get a field name for recognised amount.Please

  • Possible to do PageBreaks with Javascript?

    Hi, i like to know if it's possible to initiate page breaks in my form with Java script. There are attributes like Subform.break and Subform.break.before(target) but I can't get them to work properly... can anyone post a correct syntax for these feat

  • When you open a new tab, how do you change the site it goes to?

    My Daughter downloaded accidently a tool bar, Searchqu.com. I have removed the tool bar and application, and reset the homepage. However when I open a new tab it defaults to http://www.searchqu.com/, how do I change this? I have tried resetting it to

  • HTML link in WebDB

    I want to create a link from a drawing name in a report to a drawing file. The link is made up of a drawing name and revision which are columns on the report. Is it possible to do this with WebDB? Example: drawing number = 001-1234-25 revision = A HT

  • Help on performing an I phone reboot through I tunes??

    My phone will not reset and is stuck in a reboot loop. Im not sure if there is a fix for this, does anyone know?