"Java" is too generic. I assume you mean Swing; you might as well be talking about JavaFX here. Your requirement is a bit odd and very much conflicting in any case. There is no such thing as a generic event listener, there are specific listeners for specific events.
In stead of asking how to technically implement something, why don't you explain what you want to functionally achieve?