java - JTabbedPane: How to restrict user from moving out of current tab -


how can restrict user going away current tab. need show confirmation message save/discard changes before leaving current tab. how can implement functionality in jtabbedpane?

you override setselectedindex in jtabbedpane object, called before change takes place. if this, remember call super.setselectedindex after displayed confirmation.

alternatively, eng.fouad states, add changelistener , display confirmation message there, happens after tab has been changed, confirmation message display after new tab has been displayed on screen: http://www.java2s.com/tutorial/java/0240__swing/listeningforselectedtabchanges.htm

the second option easier implement if can live fact new tab displayed when confirmation pops up.


Comments

Popular posts from this blog

c# - how to write client side events functions for the combobox items -

exception - Python, pyPdf OCR error: pyPdf.utils.PdfReadError: EOF marker not found -