Interface IPing

All Superinterfaces:
EventListener
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface IPing extends EventListener
Listener interface for receiving periodic Ping callbacks.

This is a very small, Swing-friendly timing mechanism: a Ping object uses a javax.swing.Timer internally and notifies all registered IPing listeners on the Swing Event Dispatch Thread (EDT) at a fixed interval.

Typical usage:


 Ping ping = new Ping(1000); // fire every second
 ping.addPingListener(() -> {
 	// do something inexpensive on the EDT
 });
 
Implementations should return quickly, since all invocations occur on the EDT and long-running work will block the GUI.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Called whenever the associated Ping timer fires.
  • Method Details

    • ping

      void ping()
      Called whenever the associated Ping timer fires.

      This method is always invoked on the Swing Event Dispatch Thread (EDT). Implementations should perform only lightweight operations and delegate any long-running work to a background thread.