Package io.github.jonestimd.swing.window
Class ConfirmCloseAdapter
- java.lang.Object
-
- java.awt.event.WindowAdapter
-
- io.github.jonestimd.swing.window.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 aPredicate
and if the result istrue
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 newConfirmCloseAdapter
on a window.void
windowClosing(java.awt.event.WindowEvent e)
-
-
-
Method Detail
-
install
public static void install(java.awt.Window window, java.util.function.Predicate<java.awt.event.WindowEvent> confirmClose)
Install a newConfirmCloseAdapter
on a window.- Parameters:
window
- the windowconfirmClose
- thePredicate
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 interfacejava.awt.event.WindowListener
- Overrides:
windowClosing
in classjava.awt.event.WindowAdapter
-
-