How to override the Netbeans Platform (x) button or the netbeans platform default close operation

"JasonVanBiezen" <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <[email protected]>
Hello Wade!  I did try window listeners to control the netbeans platform before adding the shutdown code to the ModuleInstaller's closing() method per Steven's suggestion.  I have since removed the window listeners.  Thank you for linking the OnStop annotation example.  

I am using the JOptionPane.showConfirmDialog to prompt the user before exiting and it is working as intended.  My shutdown code is called in the same block as the showConfirmDialog.  

Thanks again, I really appreciate everyone taking the time to help me out :)


Wade Chandler wrote:
> I notice you mentioned window listeners. You don't happen to shut down the JVM outside the LifecycleManager or RCP do you? That could cause some oddities for sure. What did your closing implementation look like? I suggest making the simplest example of a platform app using closing and how you want it to work and see how that works, and if not working, make it something you can share on GitHub or Bitbucket to get help. 
> You can also see this:
> http://bits.netbeans.org/8.1/javadoc/org-openide-modules/org/openide/modules/OnStop.html (http://bits.netbeans.org/8.1/javadoc/org-openide-modules/org/openide/modules/OnStop.html) 
> Where the callables ask if it is OK, and the runnables allow you to cleanup if you allow the shutdown. 
> If you are questioning the user, you need to be sure you are using some synchronous question ... Modal Dialog ... Or block some other way ... Like  invokeAndWait ...To return your answer. If you don't do that, then you may not be returning when you think you are; just being sure. 
> Wade 
> On Sep 30, 2016 12:30 PM, "JasonVanBiezen" <address-removed (address-removed)> wrote:
> > Hello everyone, I've been using NetBeans Platform for a little while now and I've run into a problem of handling unsaved changes when the (x) button in the upper right hand corner is clicked to exit the app.
> > 
> > I've tried adding WindowAdapters to the WindowStateListener and WindowListener, as well as overriding the installers closing() method but the app still just exits immediately.  :?
> > 
> > What is the proper method for overriding a Netbeans Platform app's default exit behavior?
> > 
> > Thanks!    :)
> > 
> > 
> > 
> > 
> > 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.