# Prevent pop-up window from closing

**URL:** <https://forum.inductiveautomation.com/t/prevent-pop-up-window-from-closing/15630>\
**Category:** Ignition\
**Created:** [October 10, 2017, 8:24pm UTC](https://forum.inductiveautomation.com/t/prevent-pop-up-window-from-closing/15630 "2017-10-10T20:24:14Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![pphillips](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@pphillips](https://forum.inductiveautomation.com/u/pphillips)\
**Post date:** [October 10, 2017, 9:42pm UTC](https://forum.inductiveautomation.com/t/prevent-pop-up-window-from-closing/15630/2 "2017-10-10T21:42:05Z")

</div>

Try this:

```auto
from javax.swing import JOptionPane

pane = JOptionPane()

strMessage = "<html><center>Are you sure you want to close this pop-up?<br><br>Any unsaved data will be lost!"
strTitle = "Confirm Close"
frame = None

btnOpts = JOptionPane.OK_CANCEL_OPTION
msgType = JOptionPane.WARNING_MESSAGE
icon = None
options=["OK", "Cancel"]

idxResult = pane.showOptionDialog(frame, strMessage, strTitle, btnOpts, msgType, icon, options, options[1])

If idxResult == 0:
   [Close window code]

```

For more info on Java swing dialogs, see: [http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html](http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html)

---

_[View the full topic](https://forum.inductiveautomation.com/t/prevent-pop-up-window-from-closing/15630)._
