handing window closing envent question.

Posted on 2006-04-05
Last Modified: 2010-03-31
i want before window is close by user (click on window x button), my application ask and give user a last change by show yes no dialog ,if yes do close window if no, rollback (do nothing, window still visible) i listening on windowClosing event but i don't know how to rollback, here my code

        f.addWindowListener(new WindowAdapter() {
                                public void windowClosing(WindowEvent e) {
                                    if(showQuestionDialog("Would you like shutdown application?","Confirm message")==true){

f is my JFrame. whatever user choose yes or no, window still close, please help me
Question by:khacduyst

    Author Comment

    showQuesionDialog() function return true if yes and false for another option
    LVL 92

    Accepted Solution

    set the default close operation of your fema eto do nothing


    do this when you create frame

    Author Comment

    thanks for very quick reply : )
    LVL 92

    Expert Comment

    no worries :)

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
    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.

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now