[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

adding JOptionPane to closing the window

Posted on 2004-08-06
3
Medium Priority
?
335 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
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month18 days, 21 hours left to enroll

834 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