Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8683385
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:01:51+00:00 2026-06-12T22:01:51+00:00

I am buliding an NetBeans Platform application. When the user clicks on the X

  • 0

I am buliding an NetBeans Platform application. When the user clicks on the X of the main window I want the application to do nothing and show a password JDialog. If the password is correct close the app, else do not close the app. How do I do this? I’ve created a Listener class that will show the password JDialog, but how do I stop the application from closing? Similar to JFrame’s setDefaultCloseOperation, and setting it to do nothing on close.

    public class Listener extends WindowAdapter {

        private Frame frame;

        @Override
        public void windowActivated(WindowEvent event) {
            frame = WindowManager.getDefault().getMainWindow();
            frame.setSize(946, 768);
        }

        @Override
        public void windowClosing(WindowEvent event) {
            ShutDownMainWindowJDialog shutDownMainWindowJDialog;
            shutDownMainWindowJDialog = new ShutDownMainWindowJDialog(null, true);
            shutDownMainWindowJDialog.exeShutDownMainWindowJDialog();
            shutDownMainWindowJDialog.setLocationRelativeTo(frame);
            shutDownMainWindowJDialog.setVisible(true);
        }
    }

public class Installer extends ModuleInstall {

    @Override
    public void restored() {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                Frame frame = WindowManager.getDefault().getMainWindow();
                frame.addWindowListener(new Listener());
            }
        });
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:01:52+00:00Added an answer on June 12, 2026 at 10:01 pm

    It is easy. So create module with installer and overwrite method closing (may by), then show your dialog and return false (not close app). Jirka

    So this is conclusion:
    add to your module installer/activator

    package master;
    
    import org.openide.modules.ModuleInstall;
    
    /**
     * Manages a module's lifecycle. Remember that an installer is optional and
     * often not needed at all.
     */
    
    public class Installer extends ModuleInstall {
    
     @Override
     public void close() {
      //your module shutdown
     }
    
     @Override
     public boolean closing() {
    
     // this is place for your Dialog() and return:
     //
     //        true if you want to enable close the app
     //        other return false
    /*
     if you force shutdown app try LifecycleManager.getDefault().exit();
     System.exit(0) is very dummy, because it does not respect betweenmodule dependencyis
    
     }  
    }
    

    Jirka

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are building an application based on the Netbeans Platform, and one part of
I am currently building a small visual designer using the Netbeans Platform. All my
I am building an application with NetBeans and I need to increase the heap-size.
I have a simple application using netbeans for developing and maven for building et
I'm building app in Netbeans Platform 7.1, and the problem is that the menu
In Netbeans 6.5, I've got two different C++ application projects - my application and
I am looking for a cross platform RAD IDE with GUI building. NetBeans looks
I'm using NetBeans IDE 7.0.1 and Glassfish 3.0.1. I'm building a J2EE application with
I currently have a Maven application within Netbeans. Since I need to use regular
I'm developing web application in jsp/servlet,i had an issue with netbeans and Java. My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.