Package edu.cnu.mdi.util
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.
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
-
Method Details
-
ping
void ping()Called whenever the associatedPingtimer 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.
-