Class ConfirmCloseAdapter

  • All Implemented Interfaces:
    java.awt.event.WindowFocusListener, java.awt.event.WindowListener, java.awt.event.WindowStateListener, java.util.EventListener

    public class ConfirmCloseAdapter
    extends java.awt.event.WindowAdapter
    This class handles window closing events. It checks a Predicate and if the result is true then a confirmation dialog is displayed before the window closes.
    • Constructor Summary

      Constructors 
      Constructor Description
      ConfirmCloseAdapter​(java.util.function.Predicate<java.awt.event.WindowEvent> confirmClose)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void install​(java.awt.Window window, java.util.function.Predicate<java.awt.event.WindowEvent> confirmClose)
      Install a new ConfirmCloseAdapter on a window.
      void windowClosing​(java.awt.event.WindowEvent e)  
      • Methods inherited from class java.awt.event.WindowAdapter

        windowActivated, windowClosed, windowDeactivated, windowDeiconified, windowGainedFocus, windowIconified, windowLostFocus, windowOpened, windowStateChanged
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ConfirmCloseAdapter

        public ConfirmCloseAdapter​(java.util.function.Predicate<java.awt.event.WindowEvent> confirmClose)
        Parameters:
        confirmClose - the Predicate to check to determine if confirmation is required before closing the window
    • Method Detail

      • install

        public static void install​(java.awt.Window window,
                                   java.util.function.Predicate<java.awt.event.WindowEvent> confirmClose)
        Install a new ConfirmCloseAdapter on a window.
        Parameters:
        window - the window
        confirmClose - the Predicate to check to determine if confirmation is required before closing the window
      • windowClosing

        public void windowClosing​(java.awt.event.WindowEvent e)
        Specified by:
        windowClosing in interface java.awt.event.WindowListener
        Overrides:
        windowClosing in class java.awt.event.WindowAdapter