trampoline : Java Glossary
Every anonymous (or named) inner class you create for an EventListener consumes about
3K overhead. There are several ways to reduce that
overhead. One is to use a single Listener object and get it to field events for
several components. Another is to use trampolines.
Trampolines use reflection to save the overhead of inner classes. You may say,
But isn’t that slow? No because the overhead of a
single reflection call per button press is negligible. Even the slowest machine can
do over a hundred such calls a second. The key is a generic ActionListener class. You instantiate one such object per
ActionListener, though they are all the same class.
You use it like
You still have an Object per ActionListener overhead,
but that overhead is tiny, only about 16 bytes, compared with 3K per anonymous inner class. You can use the same technique for other
sorts of Listener. The beauty is you only have to write the GenericActionListener once. It can then handle all your ActionListener
needs in any application.
I would not recommend trampolines for unsigned Applets. They will likely either
trigger or will some day trigger a security exeception with their Reflection use.
Oracle’s Javadoc on ActionListener
interface : available: