?
Solved

adding JOptionPane to closing the window

Posted on 2004-08-06
3
Medium Priority
?
332 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 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month11 days, 1 hour left to enroll

770 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