Solved

adding JOptionPane to closing the window

Posted on 2004-08-06
3
330 Views
Last Modified: 2010-03-31
How would I transfer this JoptionPane to my standard window closing? There won't be a button just the x at the top of the window.

public windowVerify(){  
                                                  JButton close = new JButton("Close");
                                                  close.addMouseListener(new MouseAdapter(){
                                                       public void mouseClicked(MouseEvent e){
                                                            JOptionPane dlg = new JOptionPane();
                        if(JOptionPane.OK_OPTION==dlg.showConfirmDialog(null,"Want to exit ?","Message",JOptionPane.YES_NO_OPTION ))
                                                                 System.exit(0);
                                                       }
                                                  });
getContentPane ().setLayout(new FlowLayout());
getContentPane ().add(close);
                                             }

 public void windowClosing(WindowEvent e)
            { // Opens windowClosing method
                System.exit(0);
            } // Closes windowClosing method
        }); // Closes addWindowListener method
0
Comment
Question by:Drop_of_Rain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 11741700
public void windowClosing(WindowEvent e)
            { // Opens windowClosing method
 if(JOptionPane.OK_OPTION==JOptionPane.showConfirmDialog(null,"Want to exit ?","Message",JOptionPane.YES_NO_OPTION ))
                                                                 System.exit(0);
            } // Closes windowClosing method
        }); // Closes addWindowListener method
0
 

Author Comment

by:Drop_of_Rain
ID: 11741709
I though that was it I should of tried it first. Thanks as always
0
 
LVL 92

Expert Comment

by:objects
ID: 11741713
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This video teaches viewers about errors in exception handling.
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question