org.gnu.gtk.event
Interface LifeCycleListener
public interface LifeCycleListener
This is the listener interface for receiving life cycle realted events for a
Widget.
An example of using this class to manage the life cycle events of an
application would be as follows:
public class MyExample {
public MyExample() {
Window window = new Window();
window.setTitle("AboutDialogExample");
window.addListener(new LifeCycleListener() {
public void lifeCycleEvent(LifeCycleEvent event) {}
public boolean lifeCycleQuery(LifeCycleEvent event) {
if (event.isOfType(LifeCycleEvent.Type.DELETE) {
Gtk.mainQuit();
}
return false;
}
}
window.showAll();
}
public static void main(String[] args) {
Gtk.init(args);
new MyExample();
Gtk.main();
}
}
If, on the other hand, you are trying to intercept window closure, you listen
for the DELETE signal, do your alternate logic, and then
return true.
This tells GTK that you have handled the event-signal and that it is not to
further propagate the signal which means that the default handler (which in
turn emits a DESTROY signal and releases the resources) will not be called.
lifeCycleEvent
public void lifeCycleEvent(LifeCycleEvent event)
This method is for all void-returning life cycle related event signals.
This covers most of the signals in
LifeCycleEvent
, with the
exception of "delete" and "destroy"; see
below
.
lifeCycleQuery
public boolean lifeCycleQuery(LifeCycleEvent event)
- true if you want to tell GTK you have handled the signal and that
it should stop propagating it. For example, if you want to stop
the Window from closing, perhaps in response to running a dialog
saying "do you wish to quit", return true if they do not. In more
normal circumstances you wish to do some cleanup before closing,
then do it here, then return false to let GTK destroy the Window.