Prompt on close closing on no

I am not sure what I am doing wrong here but if the user clicks no the program closes anyway.
//Sets a propmt for closing the window
         setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
         addWindowListener( new WindowAdapter()
           @Override
          public void windowClosing(WindowEvent e)
            int selection = JOptionPane.showConfirmDialog(null,
                             "Do you want to close the window?", "Program Title",
                             JOptionPane.YES_NO_OPTION,
                             JOptionPane.WARNING_MESSAGE);
                     if( selection == JOptionPane.YES_OPTION )
                         // If the user answered "Yes", we close the frame
                         dispose();
                         // and call System.exit(0) if the whole application
                            // should
                         // terminate:
                         System.exit(0);
                     // If the user pressed "No" we don't have to
                     // do anything.
                        else
                            if( selection == JOptionPane.NO_OPTION)
        });

::sigh:: No what you have posted has not worked or helped so far...here is the code in its entirety and I can not edit the Netbean's "setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);".
* frmLogin.java
* Created on April 9, 2008, 9:58 PM
package bookofshadows;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JOptionPane;
import org.jdom.*;
* @author  Snow Wolf
public class frmLogin extends javax.swing.JDialog {
    /** Creates new form frmLogin */
    public frmLogin(java.awt.Frame parent, boolean modal)
        super(parent, modal);
        initComponents();
         //Sets a propmt for closing the window
         setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
         addWindowListener( new WindowAdapter()
           @Override
         public void windowClosing(WindowEvent e)
            int selection = JOptionPane.showConfirmDialog(null,
                             "Do you want to close the window?", "Book of Shadows",
                             JOptionPane.YES_NO_OPTION,
                             JOptionPane.WARNING_MESSAGE);
                     if( selection == JOptionPane.YES_OPTION )
                         // If the user answered "Yes", we close the frame
                         dispose();
                         // and call System.exit(0) if the whole application
                            // should
                         // terminate:
                         System.exit(0);
                     // If the user pressed "No" or "Cancel" we don't have to
                     // do anything.
                        else
                            if( selection == JOptionPane.NO_OPTION)
                              dispose();
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
    private void initComponents() {
        btnLoginSubmit = new javax.swing.JButton();
        txtLoginUsername = new javax.swing.JTextField();
        passLoginPassword = new javax.swing.JPasswordField();
        btnLoginReset = new javax.swing.JButton();
        btnLoginCancel = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        btnLoginSubmit.setText("Submit");
        btnLoginSubmit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLoginSubmitActionPerformed(evt);
        btnLoginReset.setText("Reset");
        btnLoginReset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLoginResetActionPerformed(evt);
        btnLoginCancel.setText("Cancel");
        btnLoginCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLoginCancelActionPerformed(evt);
        jLabel1.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jLabel1.setText("Username:");
        jLabel2.setFont(new java.awt.Font("DejaVu Sans", 1, 13));
        jLabel2.setText("Password:");
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(passLoginPassword, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(btnLoginSubmit)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btnLoginReset)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(btnLoginCancel))
                        .addComponent(jLabel2)
                        .addComponent(jLabel1)
                        .addComponent(txtLoginUsername, javax.swing.GroupLayout.DEFAULT_SIZE, 185, Short.MAX_VALUE)))
                .addContainerGap())
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(txtLoginUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(passLoginPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnLoginSubmit)
                    .addComponent(btnLoginReset)
                    .addComponent(btnLoginCancel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        pack();
    }// </editor-fold>                       
    private void btnLoginSubmitActionPerformed(java.awt.event.ActionEvent evt) {                                              
        // TODO add your handling code here:
    private void btnLoginCancelActionPerformed(java.awt.event.ActionEvent evt) {                                              
        // TODO add your handling code here:
        //System.exit(0);
        windowClosing();
    private void btnLoginResetActionPerformed(java.awt.event.ActionEvent evt) {                                             
        // TODO add your handling code here:
        //txtLoginUsername..setText("");
     * @param args the command line arguments
    public static void main(String args[])
        java.awt.EventQueue.invokeLater(new Runnable()
            public void run()
                frmLogin dialog = new frmLogin(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter()
                    public void windowClosing(java.awt.event.WindowEvent e)
                        System.exit(0);
                dialog.setVisible(true);
    // Variables declaration - do not modify                    
    private javax.swing.JButton btnLoginCancel;
    private javax.swing.JButton btnLoginReset;
    private javax.swing.JButton btnLoginSubmit;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPasswordField passLoginPassword;
    private javax.swing.JTextField txtLoginUsername;
    // End of variables declaration                  
    private void windowClosing()
        int selection = JOptionPane.showConfirmDialog(null,
                             "Do you want to close the window?", "Book of Shadows",
                             JOptionPane.YES_NO_OPTION,
                             JOptionPane.WARNING_MESSAGE);
                     if( selection == JOptionPane.YES_OPTION )
                         // If the user answered "Yes", we close the frame
                         dispose();
                         // and call System.exit(0) if the whole application
                            // should
                         // terminate:
                         System.exit(0);
                     // If the user pressed "No" or "Cancel" we don't have to
                     // do anything.
                        else
                            if( selection == JOptionPane.NO_OPTION)
                              dispose();
}

Similar Messages

  • With MS 7 IE 10 when installing FP I get prompt to close IE but it is closed - I retry to no avail

    Internet explorer 10 was recently updated on my computer from IE 9.  Now I can't install Flash Player any more.  I get the prompt to close Internet Explorer so I do then the prompt shows back up.  I wait a few minutes and retry again.  Still I get the prompt to close Internet Explorer.  I retry over and over but to no avail.  This is frustrating!

    See How to close Internet Explorer and other programs running on Windows?

  • Prompted to close Explorer, but it is...

    When attempting to install Flash Player I am prompted to close Explorer, it is closed.  I hit try again, and the message just repeats over and over.  I have tried restarting the process, my computer multiple times. 
    Any suggestions?

    How to close Internet Explorer and other programs running on Windows

  • How to popup a prompt dialog when closing IE?

    Hello,every one
    How to popup a prompt dialog when closing IE by clicking the "Cross"(close) of the left-up corner?
    can you give me any suggestions?
    Thnak you!
    zhongboqing

    hi,everyone,
    I am wrong. It should be:
    How to popup a prompt dialog when closing IE by clicking the "Cross"(close) of the right-up corner?
    thank you!

  • Windows Vista Home ( with SP2) constantly reporting that Safari 5.1.2 has crashed ( usual Windows prompt to close program) yet Safari is still running although loading pages slowly. Any one seen this recently ( note no recent install or changes to Windows

    Windows Vista Home ( with SP2) constantly reporting that Safari 5.1.2 has crashed ( usual Windows prompt to close program) yet Safari is still running although loading pages slowly. Any one seen this recently ( note no recent install or changes to Windows

    Windows reports that Safari stopped working . Windows Task Manager shows webkit2webprocess.exe  process still running even after I respond to Windows prompt and close Safari ( Safari continues running after this action )

  • My outlook keeps showing an error message and prompting to close, what do I do?, my outlook keeps showing an error message and prompting to close, what do I do?

    my outlook keeps showing an error message and prompting to close, what do I do? 

    http://www.microsoft.com/mac/support
    for support for Microsoft products.

  • When installing Flash Player I get the prompt to close Dashboard Client. What is that and how do I close it?

    When installing Flash Player I get the prompt to close Dashboard Client. What is that and how do I close it?

    This link to a thread on this Adobe Flash Player forum explains how to kill (strong word) the dashboard client:
    Dashboard Client
    I assume you are using a Mac.

  • 1/2 thru the downloading process, I am prompted to close IE but it is already closed

    Hello -
    I received a prompt telling me that I didn't have Adobe Flash Player installed on my computer (it had to have been installed on my computer last night; otherwise, I wouldn't have been able to play the computer games that I do).  While trying to download it, I received a prompt telling me to close IE - which I did.  When I selected the 'continue' icon, it kept telling me to close IE, then continue.  Couldn't get past this point.  And what happened to the Flash Player that was on my computer last night when I was playing computer games that require it to be installed in order to play the games?

    Download the Adobe Flash Player installer directly by clicking one of the following links.
    Flash Player for ActiveX (Internet Explorer)
    Flash Player Plug-in (All other browsers)
    "Save" the installer - DO NOT "Run" it. Repeat: DO NOT "Run" the installer.
    RIght click your taskbar and select Task Manager or Start Task Manager, whichever your OS shows.
    In the Task Manager, under the Processes tab, look for "iexplore.exe" - NOT "explorer.exe" as this is Windows Explorer, a different app altogether.
    End ALL instances of this process, until there are none.
    Run the offline installer from your downloads folder.

  • Closing window prompts to close all tabs

    When I have separate window open, and then close it, FF prompts me to close the other tabs I have open. This was not the case in previous versions. Would prefer just to close that open window and be done with it. Is there a setting I can change?

    Hit CTRL+W to close individual tabs.

  • Install of CS4 causes Word to prompt on close of Windows

    I installed CS4 Web Premium from the DVD yesterday. Afterwards, I opened Microsoft Word 2003 and hid the additional toolbars that CS4 sticks into the Word UI.
    I have Word set to prompt me to save Normal.dot if it has been changed. Since I installed CS4 (including Acrobat Pro and Contribute) I get prompted to save Normal.dot every time I close Word. It doesn't matter whether I click Yes or No, the next time I launch Word it asks me again. 
    How can I stop this behavior (aside from disabling the prompt, which is a safety feature)? 
    Windows XP SP2 
    Charles Belov 
    [signature deleted by host]

    I seem to have solved the problem! I'm using Word 2003 in XP but I assume it should work for others.
    I created a new macro in Word named AutoClose containing the following:
    Sub AutoClose()
    NormalTemplate.Saved = True
    End Sub
    I did not assign the macro to a toolbar - it just saves into normal.dot.
    This then stops the prompt to save the Normal template when Word is closed. However, first you have to save normal.dot otherwise the macro will be lost. To do that I added a SaveAll button to a toolbar (using Tools > Customize > Commands > File and dragged Save All to the toolbar) then clicked the new button to save normal.dot before closing Word.
    Note that it doesn't matter whether "Prompt to save Normal template" is checked or not in Tools > Options > Save - it doesn't prompt either way.
    I then made normal.dot read-only to ensure that it was not changed inadvertently in the future (for example to prevent any macro viruses creeping in).
    Now if you ever want to re-save normal.dot (for example if you add a new macro) then click on the SaveAll button and save normal.dot with a different name (can't save as normal.dot since it's read-only) then rename back to normal.dot. In XP normal.dot resides in C:\Documents and Settings\[username]\Application Data\Microsoft\Templates\).

  • Opening a prompt window before closing window when click on the x box

    I was wondering if there was a way to have a prompt box asking the user if they're sure they want to close the window before closing it when the x button is clicked. Is this possible? Does anyone know how?

    Or simply override:
        /** Overridde method in JFrame */
        protected void processWindowEvent(WindowEvent e)
            if(e.getID()==WindowEvent.WINDOW_CLOSING)
                int choice = JOptionPane.showConfirmDialog( null, "Are you e?" );     
                if( choice == JOptionPane.OK_OPTION )
                    System.exit(0);
            super.processWindowEvent(e);
        }

  • IPad Safari IOS 5 window.close() closing wrong window

    When I want to close the child window(although now they open as tabs) in the parent window with javascript window.close(),the parent window was closed.
    Is this a bug or have any solution?
    Safari/7534.48.3
    My script:
    <script type="text/javascript">
      var subWin1 = null;
      function popSub() {
        subWin = window.open('myurl,'subWin1','height=200,width=200'); 
      function closeSub() {
        subWin.close();
    </script>

    I'm having the exact same problem.  On iPad Safari on iOS 5 attempting to close a popup window with close() is causing the parent window to close instead.  Every other browser, including iPhone Safari on iOS 5 it works fine.  I've been trying to come up with a workaround but haven't found anything yet.  If anyone can find a workaround please post.

  • Firefox not closing promptly when browser closed

    Firefox continues to run after being closed, and doesn't allow me to reopen a new browser window for 5 to 10+ seconds. This is a fairly recent problem and I think it began when I downloaded most recent version of Firefox/Mozilla. Very frustrating.

    The Reset Firefox feature can fix many issues by restoring Firefox to its factory default state while saving your essential information.
    Note: ''This will cause you to lose any Extensions, Open websites, and some Preferences.''
    To Reset Firefox do the following:
    #Go to Firefox > Help > Troubleshooting Information.
    #Click the "Reset Firefox" button.
    #Firefox will close and reset. After Firefox is done, it will show a window with the information that is imported. Click Finish.
    #Firefox will open with all factory defaults applied.
    Further information can be found in the [[Reset Firefox – easily fix most problems]] article.
    Did this fix your problems? Please report back to us!

  • Unable to install or uninstall because of prompts to close ie explorer

    I am being prompted by video players to download Flash player. When I check my system it tells me that flash player 11 is installed, but it does not show up under programs. When I try to uninstall or install it prompts me to close ie explorer. I close ie explorer and the same prompt just keeps coming up. I have checked my firewall and anti-virus and ie explorer settings and all seem to be correct. I have also tried turning off my firewall and antivirus. I have tried running the offline uninstall and install as administrator and still no luck. I am running windows 7 with ie 10 and use AVG free and windows firewall.

    You need to close all instances of Internet Explorer, even those running invisibly in the background.  Use the Task Manager's Processes tab to end all iexplore.exe processes.

  • Confusing prompt: Please close the following application Logtransport application (Logtransport2exe)

    I just downloaded the CC Premiere suite. When I update P-PRO and AF I get the following no apps are open -Please close the following application Logtransport application (Logtransport2exe)
    Intel® Xeon® 6-Core 12-Threads CPU 4.0 GHz Turbo
    - Workstation Main Board
    - 64 GB ECC DDR3 1600 2x Quad Channel Kit (8x 8GB)
    - nVidia Quadro K4000 3GB DDR5 Professional Graphics Card
    - 500 GB Solid State Drive (SSD) for OS & Applications
    - 1TB 7200 RPM 64MB Cache SATA 6.0GB/s Enterprise Level Drive
    - 2x DVD Burner 24X Speed SATA DVD-R, DVD+R, DVD-RW
    - Microsoft Windows 7 Professional 64-Bit Edition
    Specifications:
    Intel® Xeon® Processor E5 v2
    Liquid Cooling on CPU
    Intel X79 Chipset Workstation Main Board
    Quad Channel DDR3-1600 RAM up to 64GB
    Supports up to 4-way CrossFire or SLI GPU Configurations
    Supports SATA Raid 0, 1, 5, 10
    8-Channel Audio Onboard
    (4) Serial ATA 3GB/s Ports
    (6) Serial ATA 6GB/s Ports
    (2) Intel Gigabit Ethernet LAN (10/100/1000 Mbps)
    (4) PCI-Express x16 Slots
    (2) PCI-Express x8 Slots
    (10) USB 2.0 Ports - Back Panel
    (2) USB 3.0 Ports - Back Panel
    (2) eSATA 6Gb/s Ports - Back Panel
    (8) Audio Ports for HD Surround Channels - Back Panel
    Message was edited by: Kevin Monahan

    Hi nattate,
    Please go to task manager>processes and end the task which says Logtransport2exe. After closing the task try to update again.
    Regards,
    Vinay

Maybe you are looking for